| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
/cc Michael Klement (@mklement0) if you are interested to see and measure results. |
Sorry, something went wrong.
Add new cache for ignore case Regex-s Use StringComparer.Ordinal in the cache Use the cache in regex.cs
Co-Authored-By: Steve Lee <slee@microsoft.com>
| } | ||
| else | ||
| { | ||
| return subordinateRegexCache.GetOrAdd(patternString, key => |
There was a problem hiding this comment.
Having this lambda expression in this method will result in an instance of the helper class to be created every time NewRegex gets called, even if the query can be served by the cache.
This should be changed to the following:
else
{
if (subordinateRegexCache.Count > MaxRegexCache)
{
subordinateRegexCache.Clear();
}
var regex = new Regex(patternString, options);
return subordinateRegexCache.GetOrAdd(patternString, regex);
}Note that, the ValueFactory delegate is called outside the locks and thus it's not atomic, meaning there is no difference clearing the dictionary this way from doing it in the ValueFactory delegate.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for great comment!
Done.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
|
🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada: Handy links: |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Fix #8941
PR Context
Before the change we cached only case-insensitive Regex-s (with RegexOptions.IgnoreCase).
PR Checklist