From 06e1d8b39dc23f16985791a0ef76dc98f8b5f31f Mon Sep 17 00:00:00 2001 From: Ildar Khayrutdinov Date: Wed, 12 Jan 2022 20:37:25 +0300 Subject: [PATCH] Update src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Günther Foidl --- src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs b/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs index f00c7f5b28..2eaaeb8d90 100644 --- a/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs +++ b/src/ImageSharp/Metadata/Profiles/Exif/ExifConstants.cs @@ -14,7 +14,8 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif private const ulong UnicodeCode = 0x_55_4E_49_43_4F_44_45_00; private const ulong UndefinedCode = 0x_00_00_00_00_00_00_00_00; - private static readonly byte[] AsciiCodeBytes = { 0x41, 0x53, 0x43, 0x49, 0x49, 0, 0, 0 }; + // This uses C# compiler's optimization to refer to the data segment directly. No allocation occurs. + private static ReadOnlySpan AsciiCodeBytes => new byte[] { 0x41, 0x53, 0x43, 0x49, 0x49, 0, 0, 0 }; private static readonly byte[] JISCodeBytes = { 0x4A, 0x49, 0x53, 0, 0, 0, 0, 0 }; private static readonly byte[] UnicodeCodeBytes = { 0x55, 0x4E, 0x49, 0x43, 0x4F, 0x44, 0x45, 0 }; private static readonly byte[] UndefinedCodeBytes = { 0, 0, 0, 0, 0, 0, 0, 0 };