Skip to content

Commit 864735f

Browse files
Move check outside of the loop
1 parent 830d3e2 commit 864735f

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/ImageSharp/Processing/Processors/Quantization/DefaultPixelSamplingStrategy.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
using System.Diagnostics;
54
using SixLabors.ImageSharp.Memory;
65
using SixLabors.ImageSharp.PixelFormats;
76

@@ -84,10 +83,10 @@ public IEnumerable<Buffer2DRegion<TPixel>> EnumeratePixelRegions<TPixel>(Image<T
8483

8584
int denom = (int)ratio.Denominator;
8685
int num = (int)ratio.Numerator;
86+
DebugGuard.MustBeGreaterThan(denom, 0, "Denominator must be greater than zero.");
8787

8888
for (int pos = 0; pos < totalNumberOfRows; pos++)
8989
{
90-
DebugGuard.MustBeGreaterThan(denom, 0, "Denominator must be greater than zero.");
9190
int subPos = (int)((uint)pos % (uint)denom);
9291
if (subPos < num)
9392
{
@@ -136,7 +135,6 @@ public IEnumerable<Buffer2DRegion<TPixel>> EnumeratePixelRegions<TPixel>(ImageFr
136135

137136
int denom = (int)ratio.Denominator;
138137
int num = (int)ratio.Numerator;
139-
140138
DebugGuard.MustBeGreaterThan(denom, 0, "Denominator must be greater than zero.");
141139

142140
for (int pos = 0; pos < totalNumberOfRows; pos++)

0 commit comments

Comments
 (0)