提交 f54938f7 编写于 作者: R RoslynTeam

The LexerCache short circuits the lookup of keywords whenever the text is...

 The LexerCache short circuits the lookup of keywords whenever the text is greater than the maximum keyword length.  This was being expressed as a hard coded value instead of a named constant.  Changed it to be a named constant and added a test to make sure it is up to date with the actual max keyword length (changeset 1333104)
上级 1a35c3c2
......@@ -30,6 +30,7 @@ internal partial class LexerCache
private readonly TextKeyedCache<SyntaxTrivia> triviaMap;
private readonly TextKeyedCache<SyntaxToken> tokenMap;
private readonly CachingIdentityFactory<string, SyntaxKind> keywordKindMap;
internal const int MaxKeywordLength = 10;
internal LexerCache()
{
......@@ -47,7 +48,7 @@ internal void Free()
internal bool TryGetKeywordKind(string key, out SyntaxKind kind)
{
if (key.Length > 10)
if (key.Length > MaxKeywordLength)
{
kind = SyntaxKind.None;
return false;
......
......@@ -2629,6 +2629,17 @@ public void MoreDecimalLiterals()
AssertGoodDecimalLiteral("7922816251426433759354395033549999E-5M", "ffffffffffffffffffffffff00000000");
}
[Fact]
public void TestMaxKeywordLength()
{
int max = SyntaxFacts
.GetKeywordKinds()
.Concat(SyntaxFacts.GetContextualKeywordKinds())
.Select(SyntaxFacts.GetText)
.Max(x => x.Length);
Assert.Equal(LexerCache.MaxKeywordLength, max);
}
[WorkItem(545781, "DevDiv")]
[Fact]
public void DecimalLiteralsOtherCulture()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册