Skip to content

Commit 38fdece

Browse files
Add comments explaining that spreads always require runtime-tracked index
Added comments to clarify that when spread elements are present, we always need a runtime-tracked index variable (indexTemp is not null). Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
1 parent b5ed80e commit 38fdece

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_CollectionExpression.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ private BoundExpression CreateAndPopulateArray(BoundCollectionExpression node, A
906906
},
907907
tryOptimizeSpreadElement: (ArrayBuilder<BoundExpression> sideEffects, BoundExpression arrayTemp, BoundCollectionExpressionSpreadElement spreadElement, BoundExpression rewrittenSpreadOperand) =>
908908
{
909+
// When we have spreads, we always need a runtime-tracked index variable.
909910
Debug.Assert(indexTemp is not null);
910911

911912
if (PrepareCopyToOptimization(spreadElement, rewrittenSpreadOperand) is not var (spanSliceMethod, spreadElementAsSpan, getLengthMethod, copyToMethod))
@@ -1266,6 +1267,7 @@ private BoundExpression CreateAndPopulateList(BoundCollectionExpression node, Ty
12661267
},
12671268
tryOptimizeSpreadElement: (ArrayBuilder<BoundExpression> sideEffects, BoundExpression spanTemp, BoundCollectionExpressionSpreadElement spreadElement, BoundExpression rewrittenSpreadOperand) =>
12681269
{
1270+
// When we have spreads, we always need a runtime-tracked index variable.
12691271
Debug.Assert(indexTemp is not null);
12701272

12711273
if (PrepareCopyToOptimization(spreadElement, rewrittenSpreadOperand) is not var (spanSliceMethod, spreadElementAsSpan, getLengthMethod, copyToMethod))

0 commit comments

Comments
 (0)