Skip to content

Commit 9eec48b

Browse files
authored
Reduce allocations of BoundBinaryOperator.UncommonData (#79200)
1 parent 3ced06e commit 9eec48b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Compilers/CSharp/Portable/Lowering/ExtensionMethodReferenceRewriter.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,18 @@ public static BoundNode VisitFunctionPointerLoad(BoundTreeRewriter rewriter, Bou
241241
// Local rewriter should have already rewritten interpolated strings into their final form of calls and gotos
242242
Debug.Assert(node.InterpolatedStringHandlerData is null);
243243

244+
MethodSymbol? method = VisitMethodSymbolWithExtensionRewrite(rewriter, node.Method);
245+
TypeSymbol? constrainedToType = rewriter.VisitType(node.ConstrainedToType);
246+
247+
if (Symbol.Equals(method, node.Method, TypeCompareKind.AllIgnoreOptions) && TypeSymbol.Equals(constrainedToType, node.ConstrainedToType, TypeCompareKind.AllIgnoreOptions))
248+
{
249+
return node.Data;
250+
}
251+
244252
return BoundBinaryOperator.UncommonData.CreateIfNeeded(
245253
node.ConstantValueOpt,
246-
VisitMethodSymbolWithExtensionRewrite(rewriter, node.Method),
247-
rewriter.VisitType(node.ConstrainedToType),
254+
method,
255+
constrainedToType,
248256
node.OriginalUserDefinedOperatorsOpt);
249257
}
250258

0 commit comments

Comments
 (0)