Skip to content

Commit

Permalink
Merge pull request #1407 from SixLabors/js/TryGetSinglePixelSpan
Browse files Browse the repository at this point in the history
Optimize TryGetSinglePixelSpan
  • Loading branch information
JimBobSquarePants authored Oct 29, 2020
2 parents 42f015e + 8464a3d commit adf56a4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ImageSharp/Image{TPixel}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ public Span<TPixel> GetPixelRowSpan(int rowIndex)
public bool TryGetSinglePixelSpan(out Span<TPixel> span)
{
IMemoryGroup<TPixel> mg = this.GetPixelMemoryGroup();
if (mg.Count > 1)
if (mg.Count == 1)
{
span = default;
return false;
span = mg[0].Span;
return true;
}

span = mg.Single().Span;
return true;
span = default;
return false;
}

/// <summary>
Expand Down

0 comments on commit adf56a4

Please sign in to comment.