From 98b98cafdfa76a3309e3d9cddf3016ab647d5ccf Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 15 Feb 2020 01:18:22 +1100 Subject: [PATCH] Update EuclideanPixelMap{TPixel}.cs --- .../Dithering/EuclideanPixelMap{TPixel}.cs | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Dithering/EuclideanPixelMap{TPixel}.cs b/src/ImageSharp/Processing/Processors/Dithering/EuclideanPixelMap{TPixel}.cs index 9bbdd72c46..37924e87d4 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/EuclideanPixelMap{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/EuclideanPixelMap{TPixel}.cs @@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering } } - [MethodImpl(MethodImplOptions.AggressiveInlining)] + [MethodImpl(InliningOptions.ShortMethod)] public byte GetClosestColor(TPixel color, out TPixel match) { ReadOnlySpan paletteSpan = this.palette.Span; @@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering return this.GetClosestColorSlow(color, paletteSpan, out match); } - [MethodImpl(MethodImplOptions.NoInlining)] + [MethodImpl(InliningOptions.ShortMethod)] private byte GetClosestColorSlow(TPixel color, ReadOnlySpan palette, out TPixel match) { // Loop through the palette and find the nearest match. @@ -59,19 +59,17 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering Vector4 candidate = this.vectorCache[i]; float distance = Vector4.DistanceSquared(vector, candidate); - // Greater... Move on. - if (leastDistance < distance) + // Less than... assign. + if (distance < leastDistance) { - continue; - } - - index = i; - leastDistance = distance; + index = i; + leastDistance = distance; - // And if it's an exact match, exit the loop - if (distance == 0) - { - break; + // And if it's an exact match, exit the loop + if (distance == 0) + { + break; + } } }