Optimize HlslSourceRewriter.VisitIdentifierName

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-06 21:12:42 +01:00
1 親 5973921567
コミット 785f332581
1ファイル変更
+5 -1
+5 -1
ファイルの表示
@@ -394,7 +394,11 @@ internal abstract partial class HlslSourceRewriter : CSharpSyntaxRewriter
{
IdentifierNameSyntax updatedNode = (IdentifierNameSyntax)base.VisitIdentifierName(node)!;
if (SemanticModel.For(node).GetOperation(node) is IFieldReferenceOperation operation &&
// Only gather constants directly accessed by name. We can also pre-filter to exclude invocations
// and member access expressions, as those will be handled separately. Doing so avoids unnecessarily
// retrieving semantic information for every identifier, which would otherwise be fairly expensive.
if (node.Parent is not (InvocationExpressionSyntax or MemberAccessExpressionSyntax) &&
SemanticModel.For(node).GetOperation(node) is IFieldReferenceOperation operation &&
operation.Field.IsConst &&
operation.Type!.TypeKind != TypeKind.Enum)
{