diff --git a/src/DotRecast.Core/RcArrays.cs b/src/DotRecast.Core/RcArrays.cs index adcfd09..e8c291a 100644 --- a/src/DotRecast.Core/RcArrays.cs +++ b/src/DotRecast.Core/RcArrays.cs @@ -12,15 +12,6 @@ namespace DotRecast.Core Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Copy(Span sourceArray, int sourceIndex, Span destinationArray, int destinationIndex, int length) - { - var src = sourceArray.Slice(sourceIndex, length); - var dst = destinationArray.Slice(destinationIndex); - src.CopyTo(dst); - } - - // Type Safe Copy [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Copy(T[] sourceArray, T[] destinationArray, long length) diff --git a/src/DotRecast.Core/RcSpans.cs b/src/DotRecast.Core/RcSpans.cs new file mode 100644 index 0000000..474f492 --- /dev/null +++ b/src/DotRecast.Core/RcSpans.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.CompilerServices; + +namespace DotRecast.Core +{ + public static class RcSpans + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Copy(Span source, Span destination) + { + Copy(source, 0, destination, 0, source.Length); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void Copy(Span source, int sourceIdx, Span destination, int destinationIdx, int length) + { + var src = source.Slice(sourceIdx, length); + var dst = destination.Slice(destinationIdx); + src.CopyTo(dst); + } + } +} \ No newline at end of file diff --git a/test/DotRecast.Core.Test/RcArrayBenchmarkTests.cs b/test/DotRecast.Core.Test/RcArrayBenchmarkTests.cs index 4b5410e..3117e7d 100644 --- a/test/DotRecast.Core.Test/RcArrayBenchmarkTests.cs +++ b/test/DotRecast.Core.Test/RcArrayBenchmarkTests.cs @@ -134,9 +134,7 @@ public class RcArrayBenchmarkTests var resultSpan = Bench($"Span", _ => { var v = list[seq]; - Span src = v.src; - Span dest = v.dest; - RcArrays.Copy(src, 0, dest, 0, src.Length); + RcSpans.Copy(v.src, 0, v.dest, 0, v.src.Length); }); @@ -154,7 +152,6 @@ public class RcArrayBenchmarkTests { Console.WriteLine(""); } - } } } \ No newline at end of file