From 714d55d825eb9d193be723cd538cfaf89e8b4e21 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Fri, 7 May 2021 11:41:49 +1000 Subject: [PATCH] Reduce allocation when reading PNG chunks Previously the code would read a byte[] for every PNG chunk, irrespective of whether it was going to be stored. With this change, these arrays are only allocated when they will actually be needed. This is the .NET port of https://github.com/drewnoakes/metadata-extractor/pull/535 --- .../Formats/Png/PngChunkReader.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/MetadataExtractor/Formats/Png/PngChunkReader.cs b/MetadataExtractor/Formats/Png/PngChunkReader.cs index 47dbe7819..8c229cef5 100644 --- a/MetadataExtractor/Formats/Png/PngChunkReader.cs +++ b/MetadataExtractor/Formats/Png/PngChunkReader.cs @@ -48,6 +48,11 @@ public IEnumerable Extract(SequentialReader reader, ICollection Extract(SequentialReader reader, ICollection Extract(SequentialReader reader, ICollection