diff --git a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs
index 82fd13c7d..82bd32a02 100644
--- a/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs
+++ b/src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs
@@ -65,15 +65,8 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
FixedTableSize + 2704
};
- private static readonly byte[] CodeLengthCodeOrder = { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
-
private static readonly int NumCodeLengthCodes = CodeLengthCodeOrder.Length;
- private static readonly byte[] LiteralMap =
- {
- 0, 1, 1, 1, 0
- };
-
///
/// Initializes a new instance of the class.
///
@@ -87,6 +80,12 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
this.configuration = configuration;
}
+ // This uses C#'s compiler optimization to refer to assembly's static data directly.
+ private static ReadOnlySpan CodeLengthCodeOrder => new byte[] { 17, 18, 0, 1, 2, 3, 4, 5, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
+
+ // This uses C#'s compiler optimization to refer to assembly's static data directly.
+ private static ReadOnlySpan LiteralMap => new byte[] { 0, 1, 1, 1, 0 };
+
///
/// Decodes the image from the stream using the bitreader.
///
diff --git a/src/ImageSharp/Formats/Webp/WebpLookupTables.cs b/src/ImageSharp/Formats/Webp/WebpLookupTables.cs
index bf47b01bc..c89411435 100644
--- a/src/ImageSharp/Formats/Webp/WebpLookupTables.cs
+++ b/src/ImageSharp/Formats/Webp/WebpLookupTables.cs
@@ -239,7 +239,8 @@ namespace SixLabors.ImageSharp.Formats.Webp
}
};
- public static readonly byte[] Norm =
+ // This uses C#'s compiler optimization to refer to assembly's static data directly.
+ public static ReadOnlySpan Norm => new byte[]
{
// renorm_sizes[i] = 8 - log2(i)
7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,