未验证 提交 817603e8 编写于 作者: A Andy Gocke 提交者: GitHub

Remove capturing lambda from binding hot path (#41055)

Capturing lambdas should be avoided in core compiler code
as they generate excess allocations

Fixes #41054
上级 a694f69d
......@@ -274,15 +274,22 @@ internal BoundExpression BindToNaturalType(BoundExpression expression, Diagnosti
}
break;
case BoundTupleLiteral sourceTuple:
{
var boundArgs = ArrayBuilder<BoundExpression>.GetInstance(sourceTuple.Arguments.Length);
foreach (var arg in sourceTuple.Arguments)
{
boundArgs.Add(BindToNaturalType(arg, diagnostics, reportDefaultMissingType));
}
result = new BoundConvertedTupleLiteral(
sourceTuple.Syntax,
sourceTuple,
wasTargetTyped: false,
sourceTuple.Arguments.SelectAsArray(e => BindToNaturalType(e, diagnostics, reportDefaultMissingType)),
boundArgs.ToImmutableAndFree(),
sourceTuple.ArgumentNamesOpt,
sourceTuple.InferredNamesOpt,
sourceTuple.Type, // same type to keep original element names
sourceTuple.HasErrors).WithSuppression(sourceTuple.IsSuppressed);
}
break;
case BoundDefaultLiteral defaultExpr:
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册