Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 5059d97

Browse files
committed
Merge pull request #2854 from hackcraft/fix_range_optimisation
Bring back range optimisation, fixed for boundary case.
2 parents 87edf3b + ded3bd5 commit 5059d97

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/System.Linq/src/System/Linq/Enumerable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ public static IEnumerable<int> Range(int start, int count)
14781478

14791479
private static IEnumerable<int> RangeIterator(int start, int count)
14801480
{
1481-
for (int i = 0; i < count; i++) yield return start + i;
1481+
for (int end = start + count; start != end; start++) yield return start;
14821482
}
14831483

14841484
public static IEnumerable<TResult> Repeat<TResult>(TResult element, int count)

0 commit comments

Comments
 (0)