Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public virtual TElement[] ToArray()

TElement[] array = new TElement[count];
int[] map = SortedMap(buffer);
for (int i = 0; i != array.Length; i++)
for (int i = 0; i < array.Length; i++)
{
array[i] = buffer._items[map[i]];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public TSource[] ToArray()
}

TSource[] array = new TSource[count];
for (int i = 0, curIdx = _minIndexInclusive; i != array.Length; ++i, ++curIdx)
for (int i = 0, curIdx = _minIndexInclusive; i < array.Length; ++i, ++curIdx)
{
array[i] = _source[curIdx];
}
Comment on lines +257 to 260
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i = 0, curIdx = _minIndexInclusive; i < array.Length; ++i, ++curIdx)
{
array[i] = _source[curIdx];
}
int minIndexInclusive = _minIndexInclusive;
for (int i = 0; i < array.Length; ++i)
{
array[i] = _source[i + minIndexInclusive];
}

This feels a bit simpler to me.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public int[] ToArray()
{
int[] array = new int[_end - _start];
Comment thread
stephentoub marked this conversation as resolved.
int cur = _start;
for (int i = 0; i != array.Length; ++i)
for (int i = 0; i < array.Length; ++i)
{
array[i] = cur;
++cur;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ public TResult[] ToArray()
}

TResult[] array = new TResult[count];
for (int i = 0, curIdx = _minIndexInclusive; i != array.Length; ++i, ++curIdx)
for (int i = 0, curIdx = _minIndexInclusive; i < array.Length; ++i, ++curIdx)
{
array[i] = _selector(_source[curIdx]);
}
Expand Down