From c5e42dffa16509049774fac628f5d013f50e4ae4 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 11 Jun 2018 12:31:50 -0700 Subject: [PATCH] Eliminate allocation reading BMP file header --- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 85461c0d2..7528f36bf 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -521,8 +521,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp /// private void ReadFileHeader() { +#if NETCOREAPP2_1 + Span buffer = stackalloc byte[BmpFileHeader.Size]; +#else byte[] buffer = new byte[BmpFileHeader.Size]; - +#endif this.stream.Read(buffer, 0, BmpFileHeader.Size); this.fileHeader = BmpFileHeader.Parse(buffer);