Browse Source

Simplify loop

pull/1654/head
James Jackson-South 5 years ago
parent
commit
b47be54feb
  1. 5
      src/ImageSharp/Processing/Processors/Quantization/EuclideanPixelMap{TPixel}.cs

5
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. // Loop through the palette and find the nearest match.
int index = 0; int index = 0;
float leastDistance = float.MaxValue; float leastDistance = float.MaxValue;
ref Rgba32 rgbaPaletteRef = ref MemoryMarshal.GetReference<Rgba32>(this.rgbaPalette); for (int i = 0; i < this.rgbaPalette.Length; i++)
for (int i = 0; i < this.Palette.Length; i++)
{ {
Rgba32 candidate = Unsafe.Add(ref rgbaPaletteRef, i); Rgba32 candidate = this.rgbaPalette[i];
float distance = DistanceSquared(rgba, candidate); float distance = DistanceSquared(rgba, candidate);
// If it's an exact match, exit the loop // If it's an exact match, exit the loop

Loading…
Cancel
Save