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

Commit b75ffa4

Browse files
committed
Revert optimization in Enumerable.Range
The new implementation does not handle the edge case where Enumerable.Range enumerates up to Int32.MaxValue. If values are given such that the end value will be Int32.MaxValue, no values are enumerated. This change simply reverts that change.
1 parent 89d9448 commit b75ffa4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,8 +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 end = start + count; start < end; start++)
1476-
yield return start;
1475+
for (int i = 0; i < count; i++) yield return start + i;
14771476
}
14781477

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

0 commit comments

Comments
 (0)