Skip to content

Commit e14e5bc

Browse files
authored
Avoid reversing list just for the purpose of iteration. (#28393)
1 parent 2e1bd07 commit e14e5bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Servers/HttpSys/src/RequestProcessing/RequestContext.FeatureCollection.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,10 @@ private async Task NotifiyOnStartingAsync()
616616
return;
617617
}
618618

619-
actions.Reverse();
620619
// Execute last to first. This mimics a stack unwind.
621-
foreach (var actionPair in actions)
620+
for (var i = actions.Count - 1; i >= 0; i--)
622621
{
622+
var actionPair = actions[i];
623623
await actionPair.Item1(actionPair.Item2);
624624
}
625625
}
@@ -707,10 +707,10 @@ private async Task NotifyOnCompletedAsync()
707707
return;
708708
}
709709

710-
actions.Reverse();
711710
// Execute last to first. This mimics a stack unwind.
712-
foreach (var actionPair in actions)
711+
for (var i = actions.Count - 1; i >= 0; i--)
713712
{
713+
var actionPair = actions[i];
714714
await actionPair.Item1(actionPair.Item2);
715715
}
716716
}

0 commit comments

Comments
 (0)