diff --git a/src/ImageSharp/Memory/Buffer2DExtensions.cs b/src/ImageSharp/Memory/Buffer2DExtensions.cs
index 9fce9a4f4..6458ad7e4 100644
--- a/src/ImageSharp/Memory/Buffer2DExtensions.cs
+++ b/src/ImageSharp/Memory/Buffer2DExtensions.cs
@@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Memory
/// Copy columns of inplace,
/// from positions starting at to positions at .
///
- internal static unsafe void CopyColumns(
+ internal static unsafe void DangerousCopyColumns(
this Buffer2D buffer,
int sourceIndex,
int destIndex,
@@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Memory
int dOffset = destIndex * elementSize;
long count = columnCount * elementSize;
- Span span = MemoryMarshal.AsBytes(buffer.GetSingleMemory().Span);
+ Span span = MemoryMarshal.AsBytes(buffer.DangerousGetSingleMemory().Span);
fixed (byte* ptr = span)
{
diff --git a/src/ImageSharp/Memory/Buffer2D{T}.cs b/src/ImageSharp/Memory/Buffer2D{T}.cs
index 38ca89e59..21c19f5d5 100644
--- a/src/ImageSharp/Memory/Buffer2D{T}.cs
+++ b/src/ImageSharp/Memory/Buffer2D{T}.cs
@@ -168,10 +168,10 @@ namespace SixLabors.ImageSharp.Memory
/// Thrown when the backing group is discontiguous.
///
[MethodImpl(InliningOptions.ShortMethod)]
- internal Span GetSingleSpan()
+ internal Span DangerousGetSingleSpan()
{
// TODO: If we need a public version of this method, we need to cache the non-fast Memory of this.MemoryGroup
- return this.cachedMemory.Length != 0 ? this.cachedMemory.Span : this.GetSingleSpanSlow();
+ return this.cachedMemory.Length != 0 ? this.cachedMemory.Span : this.DangerousGetSingleSpanSlow();
}
///
@@ -183,10 +183,10 @@ namespace SixLabors.ImageSharp.Memory
/// Thrown when the backing group is discontiguous.
///
[MethodImpl(InliningOptions.ShortMethod)]
- internal Memory GetSingleMemory()
+ internal Memory DangerousGetSingleMemory()
{
// TODO: If we need a public version of this method, we need to cache the non-fast Memory of this.MemoryGroup
- return this.cachedMemory.Length != 0 ? this.cachedMemory : this.GetSingleMemorySlow();
+ return this.cachedMemory.Length != 0 ? this.cachedMemory : this.DangerousGetSingleMemorySlow();
}
///
@@ -203,10 +203,10 @@ namespace SixLabors.ImageSharp.Memory
private Memory GetRowMemorySlow(int y) => this.FastMemoryGroup.GetBoundedSlice(y * (long)this.Width, this.Width);
[MethodImpl(InliningOptions.ColdPath)]
- private Memory GetSingleMemorySlow() => this.FastMemoryGroup.Single();
+ private Memory DangerousGetSingleMemorySlow() => this.FastMemoryGroup.Single();
[MethodImpl(InliningOptions.ColdPath)]
- private Span GetSingleSpanSlow() => this.FastMemoryGroup.Single().Span;
+ private Span DangerousGetSingleSpanSlow() => this.FastMemoryGroup.Single().Span;
[MethodImpl(InliningOptions.ColdPath)]
private ref T GetElementSlow(int x, int y)
diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs
index 2ab1d8b5a..a58c20f68 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs
@@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
this.DestinationLength = destinationLength;
this.MaxDiameter = (radius * 2) + 1;
this.data = memoryAllocator.Allocate2D(this.MaxDiameter, bufferHeight, AllocationOptions.Clean);
- this.pinHandle = this.data.GetSingleMemory().Pin();
+ this.pinHandle = this.data.DangerousGetSingleMemory().Pin();
this.kernels = new ResizeKernel[destinationLength];
this.tempValues = new double[this.MaxDiameter];
}
diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
index e7207c7e6..7ade3aeee 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeWorker.cs
@@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
Span tempColSpan = this.tempColumnBuffer.GetSpan();
// When creating transposedFirstPassBuffer, we made sure it's contiguous:
- Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.GetSingleSpan();
+ Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan();
for (int y = rowInterval.Min; y < rowInterval.Max; y++)
{
@@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
// Copy previous bottom band to the new top:
// (rows <--> columns, because the buffer is transposed)
- this.transposedFirstPassBuffer.CopyColumns(
+ this.transposedFirstPassBuffer.DangerousCopyColumns(
this.workerHeight - this.windowBandHeight,
0,
this.windowBandHeight);
@@ -167,7 +167,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
private void CalculateFirstPassValues(RowInterval calculationInterval)
{
Span tempRowSpan = this.tempRowBuffer.GetSpan();
- Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.GetSingleSpan();
+ Span transposedFirstPassBufferSpan = this.transposedFirstPassBuffer.DangerousGetSingleSpan();
for (int y = calculationInterval.Min; y < calculationInterval.Max; y++)
{
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
index 4d6de7e27..91b1b9cd7 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
@@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
this.Output.WriteLine($"Component{i}: {diff}");
averageDifference += diff.average;
totalDifference += diff.total;
- tolerance += libJpegComponent.SpectralBlocks.GetSingleSpan().Length;
+ tolerance += libJpegComponent.SpectralBlocks.DangerousGetSingleSpan().Length;
}
averageDifference /= componentCount;
diff --git a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs
index c93eb41c2..7d4f2da42 100644
--- a/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs
+++ b/tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs
@@ -361,7 +361,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers
in operation);
// Assert:
- TestImageExtensions.CompareBuffers(expected.GetSingleSpan(), actual.GetSingleSpan());
+ TestImageExtensions.CompareBuffers(expected.DangerousGetSingleSpan(), actual.DangerousGetSingleSpan());
}
}
diff --git a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs
index bb75578a4..27188b0b4 100644
--- a/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs
+++ b/tests/ImageSharp.Tests/Image/ImageTests.WrapMemory.cs
@@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests
using (var image = Image.WrapMemory(memory, bmp.Width, bmp.Height))
{
- Assert.Equal(memory, image.GetRootFramePixelBuffer().GetSingleMemory());
+ Assert.Equal(memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory());
Assert.True(image.TryGetSinglePixelSpan(out Span imageSpan));
imageSpan.Fill(bg);
for (var i = 10; i < 20; i++)
@@ -196,7 +196,7 @@ namespace SixLabors.ImageSharp.Tests
using (var image = Image.WrapMemory(memoryManager, bmp.Width, bmp.Height))
{
- Assert.Equal(memoryManager.Memory, image.GetRootFramePixelBuffer().GetSingleMemory());
+ Assert.Equal(memoryManager.Memory, image.GetRootFramePixelBuffer().DangerousGetSingleMemory());
Assert.True(image.TryGetSinglePixelSpan(out Span imageSpan));
imageSpan.Fill(bg);
for (var i = 10; i < 20; i++)
@@ -255,7 +255,7 @@ namespace SixLabors.ImageSharp.Tests
using (var image = Image.WrapMemory(byteMemory, bmp.Width, bmp.Height))
{
Span pixelSpan = pixelMemory.Span;
- Span imageSpan = image.GetRootFramePixelBuffer().GetSingleMemory().Span;
+ Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span;
// We can't compare the two Memory instances directly as they wrap different memory managers.
// To check that the underlying data matches, we can just manually check their lenth, and the
@@ -327,7 +327,7 @@ namespace SixLabors.ImageSharp.Tests
using (var image = Image.WrapMemory(p, bmp.Width, bmp.Height))
{
Span pixelSpan = pixelMemory.Span;
- Span imageSpan = image.GetRootFramePixelBuffer().GetSingleMemory().Span;
+ Span imageSpan = image.GetRootFramePixelBuffer().DangerousGetSingleMemory().Span;
Assert.Equal(pixelSpan.Length, imageSpan.Length);
Assert.True(Unsafe.AreSame(ref pixelSpan.GetPinnableReference(), ref imageSpan.GetPinnableReference()));
diff --git a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs
index 549ecb7f4..015b3617b 100644
--- a/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs
+++ b/tests/ImageSharp.Tests/Memory/Buffer2DTests.cs
@@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
Assert.Equal(width, buffer.Width);
Assert.Equal(height, buffer.Height);
Assert.Equal(0, buffer.FastMemoryGroup.TotalLength);
- Assert.Equal(0, buffer.GetSingleSpan().Length);
+ Assert.Equal(0, buffer.DangerousGetSingleSpan().Length);
}
}
@@ -87,7 +87,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
{
using (Buffer2D buffer = this.MemoryAllocator.Allocate2D(42, 42, AllocationOptions.Clean))
{
- Span span = buffer.GetSingleSpan();
+ Span span = buffer.DangerousGetSingleSpan();
for (int j = 0; j < span.Length; j++)
{
Assert.Equal(0, span[j]);
@@ -249,9 +249,9 @@ namespace SixLabors.ImageSharp.Tests.Memory
var rnd = new Random(123);
using (Buffer2D b = this.MemoryAllocator.Allocate2D(width, height))
{
- rnd.RandomFill(b.GetSingleSpan(), 0, 1);
+ rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1);
- b.CopyColumns(startIndex, destIndex, columnCount);
+ b.DangerousCopyColumns(startIndex, destIndex, columnCount);
for (int y = 0; y < b.Height; y++)
{
@@ -271,10 +271,10 @@ namespace SixLabors.ImageSharp.Tests.Memory
var rnd = new Random(123);
using (Buffer2D b = this.MemoryAllocator.Allocate2D(100, 100))
{
- rnd.RandomFill(b.GetSingleSpan(), 0, 1);
+ rnd.RandomFill(b.DangerousGetSingleSpan(), 0, 1);
- b.CopyColumns(0, 50, 22);
- b.CopyColumns(0, 50, 22);
+ b.DangerousCopyColumns(0, 50, 22);
+ b.DangerousCopyColumns(0, 50, 22);
for (int y = 0; y < b.Height; y++)
{
diff --git a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
index de365c429..26378796b 100644
--- a/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/TestImageExtensions.cs
@@ -672,7 +672,7 @@ namespace SixLabors.ImageSharp.Tests
var image = new Image(buffer.Width, buffer.Height);
Assert.True(image.Frames.RootFrame.TryGetSinglePixelSpan(out Span pixels));
- Span bufferSpan = buffer.GetSingleSpan();
+ Span bufferSpan = buffer.DangerousGetSingleSpan();
for (int i = 0; i < bufferSpan.Length; i++)
{