1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-13 22:12:43 +01:00

Merge pull request #11847 from xokdvium/dev/some-vector-reserves

refactor(treewide): reserve vector capacity when final size is known
This commit is contained in:
Jörg Thalheim 2024-11-09 21:49:36 +01:00 committed by GitHub
commit cdcf9bd2fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 6 additions and 0 deletions

View file

@ -66,6 +66,7 @@ std::vector<KeyedBuildResult> Store::buildPathsWithResults(
worker.run(goals);
std::vector<KeyedBuildResult> results;
results.reserve(state.size());
for (auto & [req, goalPtr] : state)
results.emplace_back(KeyedBuildResult {

View file

@ -37,6 +37,7 @@ DerivedPath StorePathWithOutputs::toDerivedPath() const
std::vector<DerivedPath> toDerivedPaths(const std::vector<StorePathWithOutputs> ss)
{
std::vector<DerivedPath> reqs;
reqs.reserve(ss.size());
for (auto & s : ss) reqs.push_back(s.toDerivedPath());
return reqs;
}