mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02: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:
commit
cdcf9bd2fa
6 changed files with 6 additions and 0 deletions
|
@ -857,6 +857,7 @@ std::vector<FlakeRef> RawInstallablesCommand::getFlakeRefsForCompletion()
|
|||
{
|
||||
applyDefaultInstallables(rawInstallables);
|
||||
std::vector<FlakeRef> res;
|
||||
res.reserve(rawInstallables.size());
|
||||
for (auto i : rawInstallables)
|
||||
res.push_back(parseFlakeRefWithFragment(
|
||||
fetchSettings,
|
||||
|
|
|
@ -91,6 +91,7 @@ StringMap EvalState::realiseContext(const NixStringContext & context, StorePathS
|
|||
|
||||
/* Build/substitute the context. */
|
||||
std::vector<DerivedPath> buildReqs;
|
||||
buildReqs.reserve(drvs.size());
|
||||
for (auto & d : drvs) buildReqs.emplace_back(DerivedPath { d });
|
||||
buildStore->buildPaths(buildReqs, bmNormal, store);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ ExecutablePath ExecutablePath::parse(const OsString & path)
|
|||
OsString ExecutablePath::render() const
|
||||
{
|
||||
std::vector<PathViewNG> path2;
|
||||
path2.reserve(directories.size());
|
||||
for (auto & p : directories)
|
||||
path2.push_back(p.native());
|
||||
return basicConcatStringsSep(path_var_separator, path2);
|
||||
|
|
|
@ -610,6 +610,7 @@ struct CmdDevelop : Common, MixEnvironment
|
|||
|
||||
else if (!command.empty()) {
|
||||
std::vector<std::string> args;
|
||||
args.reserve(command.size());
|
||||
for (auto s : command)
|
||||
args.push_back(shellEscape(s));
|
||||
script += fmt("exec %s\n", concatStringsSep(" ", args));
|
||||
|
|
Loading…
Reference in a new issue