Skip to content

Commit a5d4331

Browse files
committed
Stop boxing to compare the SyntaxKind enum during tokenization
This accounts for a significant portion of razor's allocations during parsing.
1 parent aeb28d4 commit a5d4331

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/LanguageCharacteristics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public virtual bool IsUnknown(SyntaxToken token)
8080

8181
public virtual bool IsKnownTokenType(SyntaxToken token, KnownTokenType type)
8282
{
83-
return token != null && Equals(token.Kind, GetKnownTokenType(type));
83+
return token != null && (token.Kind == GetKnownTokenType(type));
8484
}
8585

8686
public virtual Tuple<SyntaxToken, SyntaxToken> SplitToken(SyntaxToken token, int splitAt, SyntaxKind leftType)
@@ -100,7 +100,7 @@ public virtual Tuple<SyntaxToken, SyntaxToken> SplitToken(SyntaxToken token, int
100100

101101
public virtual bool KnowsTokenType(KnownTokenType type)
102102
{
103-
return type == KnownTokenType.Unknown || !Equals(GetKnownTokenType(type), GetKnownTokenType(KnownTokenType.Unknown));
103+
return type == KnownTokenType.Unknown || (GetKnownTokenType(type) != GetKnownTokenType(KnownTokenType.Unknown));
104104
}
105105

106106
protected abstract SyntaxToken CreateToken(string content, SyntaxKind type, RazorDiagnostic[] errors);

0 commit comments

Comments
 (0)