Skip to content

Commit

Permalink
Improve CollectionIterator.CopyTo
Browse files Browse the repository at this point in the history
  • Loading branch information
viceroypenguin committed Aug 31, 2023
1 parent 00b21d4 commit cccf1ff
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions Source/SuperLinq/CollectionIterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ public virtual void CopyTo(T[] array, int arrayIndex)
Guard.IsNotNull(array);
Guard.IsBetweenOrEqualTo(arrayIndex, 0, array.Length - Count);

if (Count + arrayIndex > array.Length)
ThrowHelper.ThrowArgumentException(nameof(array), "Destination is not long enough.");

var i = arrayIndex;
foreach (var el in GetEnumerable())
array[i++] = el;
_ = SuperEnumerable.CopyTo(GetEnumerable(), array, arrayIndex);
}
}
}

0 comments on commit cccf1ff

Please sign in to comment.