From b47be54feb89c1452b1de3de068a96fdb222232b Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 5 Jun 2021 13:40:21 +0100 Subject: [PATCH] Simplify loop --- .../Processors/Quantization/EuclideanPixelMap{TPixel}.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs index 1342de9dc7..5a6adc35f4 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs @@ -72,10 +72,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization // Loop through the palette and find the nearest match. int index = 0; float leastDistance = float.MaxValue; - ref Rgba32 rgbaPaletteRef = ref MemoryMarshal.GetReference(this.rgbaPalette); - for (int i = 0; i < this.Palette.Length; i++) + for (int i = 0; i < this.rgbaPalette.Length; i++) { - Rgba32 candidate = Unsafe.Add(ref rgbaPaletteRef, i); + Rgba32 candidate = this.rgbaPalette[i]; float distance = DistanceSquared(rgba, candidate); // If it's an exact match, exit the loop