Skip to content

Commit 4b84aec

Browse files
committed
Reverted some pinning changes to have less verbose C# code
1 parent f348d70 commit 4b84aec

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ internal static unsafe void ByteToNormalizedFloat(
673673
ReadOnlySpan<byte> source,
674674
Span<float> dest)
675675
{
676-
fixed (byte* sourceBase = &MemoryMarshal.GetReference(source))
676+
fixed (byte* sourceBase = source)
677677
{
678678
if (Avx2.IsSupported)
679679
{

src/ImageSharp/Compression/Zlib/Adler32.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ private static unsafe uint CalculateScalar(uint adler, ReadOnlySpan<byte> buffer
387387
uint s1 = adler & 0xFFFF;
388388
uint s2 = (adler >> 16) & 0xFFFF;
389389

390-
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer))
390+
fixed (byte* bufferPtr = buffer)
391391
{
392392
byte* localBufferPtr = bufferPtr;
393393
uint length = (uint)buffer.Length;

src/ImageSharp/Compression/Zlib/Crc32.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private static unsafe uint CalculateSse(uint crc, ReadOnlySpan<byte> buffer)
8181
int chunksize = buffer.Length & ~ChunksizeMask;
8282
int length = chunksize;
8383

84-
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer))
84+
fixed (byte* bufferPtr = buffer)
8585
{
8686
fixed (ulong* k05PolyPtr = K05Poly)
8787
{
@@ -201,7 +201,7 @@ private static unsafe uint CalculateSse(uint crc, ReadOnlySpan<byte> buffer)
201201
[MethodImpl(InliningOptions.HotPath | InliningOptions.ShortMethod)]
202202
private static unsafe uint CalculateArm(uint crc, ReadOnlySpan<byte> buffer)
203203
{
204-
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer))
204+
fixed (byte* bufferPtr = buffer)
205205
{
206206
byte* localBufferPtr = bufferPtr;
207207
int len = buffer.Length;
@@ -248,7 +248,7 @@ private static unsafe uint CalculateArm(uint crc, ReadOnlySpan<byte> buffer)
248248
[MethodImpl(InliningOptions.HotPath | InliningOptions.ShortMethod)]
249249
private static unsafe uint CalculateArm64(uint crc, ReadOnlySpan<byte> buffer)
250250
{
251-
fixed (byte* bufferPtr = &MemoryMarshal.GetReference(buffer))
251+
fixed (byte* bufferPtr = buffer)
252252
{
253253
byte* localBufferPtr = bufferPtr;
254254
int len = buffer.Length;

src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public static void PredictorInverseTransform(
569569
Span<uint> pixelData,
570570
Span<uint> outputSpan)
571571
{
572-
fixed (uint* inputFixed = &MemoryMarshal.GetReference(pixelData))
572+
fixed (uint* inputFixed = pixelData)
573573
{
574574
fixed (uint* outputFixed = outputSpan)
575575
{

src/ImageSharp/Formats/Webp/Lossless/PredictorEncoder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ private static void GetResidual(
353353
else
354354
{
355355
#pragma warning disable SA1503 // Braces should not be omitted
356-
fixed (uint* currentRow = &MemoryMarshal.GetReference(currentRowSpan))
357-
fixed (uint* upperRow = &MemoryMarshal.GetReference(upperRowSpan))
356+
fixed (uint* currentRow = currentRowSpan)
357+
fixed (uint* upperRow = upperRowSpan)
358358
{
359359
for (int x = xStart; x < xEnd; x++)
360360
{
@@ -664,9 +664,9 @@ private static void PredictBatch(
664664
Span<short> scratch)
665665
{
666666
#pragma warning disable SA1503 // Braces should not be omitted
667-
fixed (uint* current = &MemoryMarshal.GetReference(currentSpan))
668-
fixed (uint* upper = &MemoryMarshal.GetReference(upperSpan))
669-
fixed (uint* outputFixed = &MemoryMarshal.GetReference(outputSpan))
667+
fixed (uint* current = currentSpan)
668+
fixed (uint* upper = upperSpan)
669+
fixed (uint* outputFixed = outputSpan)
670670
{
671671
uint* output = outputFixed;
672672
if (xStart == 0)

src/ImageSharp/Formats/Webp/WebpCommonUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static unsafe bool CheckNonOpaque(Span<Bgra32> row)
8181
ReadOnlySpan<byte> rowBytes = MemoryMarshal.AsBytes(row);
8282
int i = 0;
8383
int length = (row.Length * 4) - 3;
84-
fixed (byte* src = &MemoryMarshal.GetReference(rowBytes))
84+
fixed (byte* src = rowBytes)
8585
{
8686
for (; i + 64 <= length; i += 64)
8787
{

src/ImageSharp/Memory/Buffer2DExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ internal static unsafe void DangerousCopyColumns<T>(
5050

5151
Span<byte> span = MemoryMarshal.AsBytes(buffer.DangerousGetSingleMemory().Span);
5252

53-
fixed (byte* ptr = &MemoryMarshal.GetReference(span))
53+
fixed (byte* ptr = span)
5454
{
5555
byte* basePtr = ptr;
5656
for (int y = 0; y < buffer.Height; y++)

0 commit comments

Comments
 (0)