提交 f5d36158 编写于 作者: N Neal Gafter

Clarify a comment for DecisionDagBuilder.TranslatePattern.

Improve handling of array builder in in LocalRewriter.LowerIsPattern
上级 69b82e44
......@@ -26,7 +26,7 @@ internal DecisionDagBuilder(CSharpCompilation compilation)
}
/// <summary>
/// Used to translate the pattern of an is-pattern expression.
/// Used to translate the pattern of an is-pattern expression. Returns the BoundDagTemp used to represent the root (input).
/// </summary>
public BoundDagTemp TranslatePattern(
BoundExpression input,
......
......@@ -289,15 +289,16 @@ public BoundExpression LowerIsPattern(BoundPattern pattern, CSharpCompilation co
result = (result == null) ? conjunct : _factory.LogicalAnd(result, conjunct);
}
var bindingsBuilder = ArrayBuilder<BoundExpression>.GetInstance();
var bindingsBuilder = ArrayBuilder<BoundExpression>.GetInstance(bindings.Length);
foreach ((BoundExpression left, BoundDagTemp right) in bindings)
{
bindingsBuilder.Add(_factory.AssignmentExpression(left, _tempAllocator.GetTemp(right)));
}
if (bindingsBuilder.Count > 0)
var bindingAssignments = bindingsBuilder.ToImmutableAndFree();
if (bindingAssignments.Length > 0)
{
BoundSequence c = _factory.Sequence(ImmutableArray<LocalSymbol>.Empty, bindingsBuilder.ToImmutableAndFree(), _factory.Literal(true));
BoundSequence c = _factory.Sequence(ImmutableArray<LocalSymbol>.Empty, bindingAssignments, _factory.Literal(true));
result = (result == null) ? c : (BoundExpression)_factory.LogicalAnd(result, c);
}
else if (result == null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册