From a131ad5236bc971d27c0f1882472b76c8dab06c8 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 | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/MetadataExtractor/Formats/Png/PngChunkReader.cs b/MetadataExtractor/Formats/Png/PngChunkReader.cs index 47dbe7819..100df7699 100644 --- a/MetadataExtractor/Formats/Png/PngChunkReader.cs +++ b/MetadataExtractor/Formats/Png/PngChunkReader.cs @@ -48,6 +48,12 @@ public IEnumerable Extract(SequentialReader reader, ICollection Extract(SequentialReader reader, ICollection Extract(SequentialReader reader, ICollection