diff --git a/src/ImageSharp/Memory/SpanHelper.cs b/src/ImageSharp/Memory/SpanHelper.cs
index 4a6b7b7ce6..592e2a885b 100644
--- a/src/ImageSharp/Memory/SpanHelper.cs
+++ b/src/ImageSharp/Memory/SpanHelper.cs
@@ -11,20 +11,6 @@ namespace SixLabors.ImageSharp.Memory
///
internal static class SpanHelper
{
- ///
- /// Copy 'count' number of elements of the same type from 'source' to 'dest'
- ///
- /// The element type.
- /// The to copy elements from.
- /// The destination .
- /// The number of elements to copy
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static unsafe void Copy(ReadOnlySpan source, Span destination, int count)
- where T : struct
- {
- source.Slice(0, count).CopyTo(destination);
- }
-
///
/// Copy all elements of 'source' into 'destination'.
///
@@ -35,7 +21,7 @@ namespace SixLabors.ImageSharp.Memory
public static void Copy(ReadOnlySpan source, Span destination)
where T : struct
{
- Copy(source, destination, Math.Min(source.Length, destination.Length));
+ source.Slice(0, Math.Min(source.Length, destination.Length)).CopyTo(destination);
}
///
diff --git a/tests/ImageSharp.Tests/Memory/SpanUtilityTests.cs b/tests/ImageSharp.Tests/Memory/SpanUtilityTests.cs
index a813e0c1dd..908830fb7c 100644
--- a/tests/ImageSharp.Tests/Memory/SpanUtilityTests.cs
+++ b/tests/ImageSharp.Tests/Memory/SpanUtilityTests.cs
@@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
var apSource = new Span(source, 1, source.Length - 1);
var apDest = new Span(dest, 1, dest.Length - 1);
- SpanHelper.Copy(apSource, apDest, count - 1);
+ apSource.Slice(0, count - 1).CopyTo(apDest);
AssertNotDefault(source, 1);
AssertNotDefault(dest, 1);
@@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
var apSource = new Span(source, 1, source.Length - 1);
var apDest = new Span(dest, 1, dest.Length - 1);
- SpanHelper.Copy(apSource, apDest, count - 1);
+ apSource.Slice(0, count - 1).CopyTo(apDest);
AssertNotDefault(source, 1);
AssertNotDefault(dest, 1);
@@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
var apSource = new Span(source, 1, source.Length - 1);
var apDest = new Span(dest, 1, dest.Length - 1);
- SpanHelper.Copy(apSource, apDest, count - 1);
+ apSource.Slice(0, count - 1).CopyTo(apDest);
AssertNotDefault(source, 1);
AssertNotDefault(dest, 1);
@@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
var apSource = new Span(source, 1, source.Length - 1);
var apDest = new Span(dest, sizeof(TestStructs.Foo), dest.Length - sizeof(TestStructs.Foo));
- SpanHelper.Copy(apSource.AsBytes(), apDest, (count - 1) * sizeof(TestStructs.Foo));
+ apSource.AsBytes().Slice(0, (count - 1) * sizeof(TestStructs.Foo)).CopyTo(apDest);
AssertNotDefault(source, 1);
@@ -159,7 +159,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
var apSource = new Span(source, 1, source.Length - 1);
var apDest = new Span(dest, sizeof(TestStructs.AlignedFoo), dest.Length - sizeof(TestStructs.AlignedFoo));
- SpanHelper.Copy(apSource.AsBytes(), apDest, (count - 1) * sizeof(TestStructs.AlignedFoo));
+ apSource.AsBytes().Slice(0, (count - 1) * sizeof(TestStructs.AlignedFoo)).CopyTo(apDest);
AssertNotDefault(source, 1);
@@ -182,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
var apSource = new Span(source);
var apDest = new Span(dest);
- SpanHelper.Copy(apSource.AsBytes(), apDest, count * sizeof(int));
+ apSource.AsBytes().Slice(0, count * sizeof(int)).CopyTo(apDest);
AssertNotDefault(source, 1);
@@ -198,12 +198,12 @@ namespace SixLabors.ImageSharp.Tests.Memory
{
int srcCount = count * sizeof(TestStructs.Foo);
byte[] source = CreateTestBytes(srcCount);
- TestStructs.Foo[] dest = new TestStructs.Foo[count + 2];
+ var dest = new TestStructs.Foo[count + 2];
var apSource = new Span(source);
var apDest = new Span(dest);
- SpanHelper.Copy(apSource, apDest.AsBytes(), count * sizeof(TestStructs.Foo));
+ apSource.Slice(0, count * sizeof(TestStructs.Foo)).CopyTo(apDest.AsBytes());
AssertNotDefault(source, sizeof(TestStructs.Foo) + 1);
AssertNotDefault(dest, 1);