Skip to content

Commit adf56a4

Browse files
Merge pull request #1407 from SixLabors/js/TryGetSinglePixelSpan
Optimize TryGetSinglePixelSpan
2 parents 42f015e + 8464a3d commit adf56a4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ImageSharp/Image{TPixel}.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ public Span<TPixel> GetPixelRowSpan(int rowIndex)
201201
public bool TryGetSinglePixelSpan(out Span<TPixel> span)
202202
{
203203
IMemoryGroup<TPixel> mg = this.GetPixelMemoryGroup();
204-
if (mg.Count > 1)
204+
if (mg.Count == 1)
205205
{
206-
span = default;
207-
return false;
206+
span = mg[0].Span;
207+
return true;
208208
}
209209

210-
span = mg.Single().Span;
211-
return true;
210+
span = default;
211+
return false;
212212
}
213213

214214
/// <summary>

0 commit comments

Comments
 (0)