From e60ba7620d99990641117a44615f3de8c88b4482 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sun, 8 Mar 2026 20:15:51 +0100 Subject: [PATCH] chore: micro-optimisation: early exit on fillUncompressedSizes (#1322) ## Summary * **What is the goal of this PR?** Avoid repeated full central-directory scans by using early stop when all requested targets are already matched. * **What changes are included?** ## Additional Context * Add any other information that might be helpful for the reviewer (e.g., performance implications, potential risks, specific areas to focus on). --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _** PARTIALLY **_ Identified by AI --- lib/ZipFile/ZipFile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ZipFile/ZipFile.cpp b/lib/ZipFile/ZipFile.cpp index a740e14d..58fa64d5 100644 --- a/lib/ZipFile/ZipFile.cpp +++ b/lib/ZipFile/ZipFile.cpp @@ -332,6 +332,7 @@ int ZipFile::fillUncompressedSizes(std::vector& targets, std::vector file.seek(zipDetails.centralDirOffset); int matched = 0; + const int targetCount = static_cast(targets.size()); uint32_t sig; char itemName[256]; @@ -372,6 +373,10 @@ int ZipFile::fillUncompressedSizes(std::vector& targets, std::vector } ++it; } + + if (matched >= targetCount) { + break; + } } else { file.seekCur(nameLen); }