From 0f02711aeecce0328d9c3657e211f123890e9fcc Mon Sep 17 00:00:00 2001 From: Alex Girard Date: Tue, 18 Oct 2022 21:05:33 -0400 Subject: [PATCH] Making MSRegexCompiledEngine properly use concurrent dictionary --- DeviceDetector.NET/RegexEngine/MSRegexCompiledEngine.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DeviceDetector.NET/RegexEngine/MSRegexCompiledEngine.cs b/DeviceDetector.NET/RegexEngine/MSRegexCompiledEngine.cs index 754ac4c..4e65584 100644 --- a/DeviceDetector.NET/RegexEngine/MSRegexCompiledEngine.cs +++ b/DeviceDetector.NET/RegexEngine/MSRegexCompiledEngine.cs @@ -15,7 +15,7 @@ public class MSRegexCompiledEngine : IRegexEngine private Regex GetRegex(string pattern) { - return _staticRegExCache.Value.GetOrAdd(pattern, new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled)); + return _staticRegExCache.Value.GetOrAdd(pattern, (regexPattern) => new Regex(regexPattern, RegexOptions.IgnoreCase | RegexOptions.Compiled)); } public bool Match(string input, string pattern) @@ -39,7 +39,7 @@ public IEnumerable MatchesUniq(string input, string pattern) { if (!match.Value.Equals(group.Value)) { - yield return group.Value; + yield return group.Value; } } } @@ -50,4 +50,4 @@ public string Replace(string input, string pattern, string replacement) return GetRegex(pattern).Replace(input, replacement); } } -} +} \ No newline at end of file