提交 457ab8ed 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #20575 from CyrusNajmabadi/patternMatchingCheck

Avoid costly check on every candidate we check against.
......@@ -27,6 +27,8 @@ private struct TextChunk : IDisposable
public readonly WordSimilarityChecker SimilarityChecker;
public readonly bool IsLowercase;
public TextChunk(string text, bool allowFuzzingMatching)
{
this.Text = text;
......@@ -34,6 +36,8 @@ public TextChunk(string text, bool allowFuzzingMatching)
this.SimilarityChecker = allowFuzzingMatching
? WordSimilarityChecker.Allocate(text, substringsAreSimilar: false)
: null;
IsLowercase = !ContainsUpperCaseLetter(text);
}
public void Dispose()
......
......@@ -187,7 +187,7 @@ private static bool ContainsUpperCaseLetter(string pattern)
}
}
var isLowercase = !ContainsUpperCaseLetter(patternChunk.Text);
var isLowercase = patternChunk.IsLowercase;
if (isLowercase)
{
if (caseInsensitiveIndex > 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册