From 44bedf78445f5454f2bf0a677396822352cb9bd5 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Mon, 10 Jul 2023 00:24:00 -0400 Subject: [PATCH] AK: Don't reuse chunks in `AllocatingMemoryStream` As confusing as it may sound, reusing them is terrible performance wise. When profiling the PNG decoder, the result (which is dominated by the Zlib decompression) shows that the `cleanup_unused_chunks()` function represented 14.26% of the profile before this patch and only 7.7% afterward. On a 6.5 MB PNG image, it reduces the decompression time by more than 5%. --- AK/MemoryStream.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/AK/MemoryStream.cpp b/AK/MemoryStream.cpp index 1f92e9146d..c65c5234cc 100644 --- a/AK/MemoryStream.cpp +++ b/AK/MemoryStream.cpp @@ -277,8 +277,6 @@ void AllocatingMemoryStream::cleanup_unused_chunks() auto buffer = m_chunks.take_first(); m_read_offset -= CHUNK_SIZE; m_write_offset -= CHUNK_SIZE; - - m_chunks.append(move(buffer)); } }