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

Commit ded3bd5

Browse files
committed
Bring back range optimisation, fixed for boundary case.
31599c5 introduced a boundary error, and was hence reverted in b75ffa4. This reintroduces the idea of 31599c5, but fixed for the boundary case.
1 parent 1144415 commit ded3bd5

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
@@ -1472,7 +1472,7 @@ public static IEnumerable<int> Range(int start, int count)
14721472

14731473
private static IEnumerable<int> RangeIterator(int start, int count)
14741474
{
1475-
for (int i = 0; i < count; i++) yield return start + i;
1475+
for (int end = start + count; start != end; start++) yield return start;
14761476
}
14771477

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

0 commit comments

Comments
 (0)