Skip to content

Commit 8464a3d

Browse files
Don't use Linq and test for common path first.
1 parent 42f015e commit 8464a3d

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)