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
This commit is contained in:
jpirnay
2026-03-08 20:15:51 +01:00
committed by GitHub
parent cd508d27d5
commit e60ba7620d

View File

@@ -332,6 +332,7 @@ int ZipFile::fillUncompressedSizes(std::vector<SizeTarget>& targets, std::vector
file.seek(zipDetails.centralDirOffset); file.seek(zipDetails.centralDirOffset);
int matched = 0; int matched = 0;
const int targetCount = static_cast<int>(targets.size());
uint32_t sig; uint32_t sig;
char itemName[256]; char itemName[256];
@@ -372,6 +373,10 @@ int ZipFile::fillUncompressedSizes(std::vector<SizeTarget>& targets, std::vector
} }
++it; ++it;
} }
if (matched >= targetCount) {
break;
}
} else { } else {
file.seekCur(nameLen); file.seekCur(nameLen);
} }