Skip to content

Switch to Span<T> or ReadOnlySpan<T> #2616

Open
@mattleibow

Description

Description

Part of #2615

The SkiaSharp codebase is quite old and existed before the introduction of spans. (See more https://learn.microsoft.com/en-us/dotnet/standard/memory-and-spans/memory-t-usage-guidelines)

Current files in the core binding using arrays:

  • Definitions.cs
  • GRGlInterface.cs
  • GRVkExtensions.cs
  • SKBitmap.cs
  • SKCanvas.cs
  • SKCodec.cs
  • SKColorFilter.cs
  • SKColorSpace.cs
  • SKColorSpaceStructs.cs
  • SKData.cs
  • SKFont.cs
  • SKFontManager.cs
  • SKFrontBufferedManagedStream.cs
  • SKFrontBufferedStream.cs
  • SKImage.cs
  • SKManagedStream.cs
  • SKManagedWStream.cs
  • SKMaskFilter.cs
  • SKMatrix.cs
  • SKMatrix44.cs
  • SKObject.cs
  • SKPMColor.cs
  • SKPaint.cs
  • SKPath.cs
  • SKPathEffect.cs
  • SKRoundRect.cs
    • Start using spans instead of arrays #2617
    • public SKPoint[] Radii { get; } still exists as it is a convenience and this is accessible using non-arrays by querying each corner individually (which is what this property does)
  • SKRuntimeEffect.cs
  • SKShader.cs
  • SKStream.cs
  • SKString.cs
  • SKTextBlob.cs
  • SKTypeface.cs
  • SKVertices.cs
  • SkiaApi.generated.cs
  • Util.cs

NOTE: not all usages are bad. There are cases where returning an array is acceptable because we have span alternatives, or the data is best contained in an array.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Ready For Work

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions