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