Skip to content

Commit

Permalink
Making MSRegexCompiledEngine properly use concurrent dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGirardDev committed Oct 19, 2022
1 parent df9026a commit 0f02711
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions DeviceDetector.NET/RegexEngine/MSRegexCompiledEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -39,7 +39,7 @@ public IEnumerable<string> MatchesUniq(string input, string pattern)
{
if (!match.Value.Equals(group.Value))
{
yield return group.Value;
yield return group.Value;
}
}
}
Expand All @@ -50,4 +50,4 @@ public string Replace(string input, string pattern, string replacement)
return GetRegex(pattern).Replace(input, replacement);
}
}
}
}

0 comments on commit 0f02711

Please sign in to comment.