aboutsummaryrefslogtreecommitdiff
path: root/src/nix-env
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-10-09 15:51:52 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-10-09 16:06:29 +0200
commit99b73fb5071db9fd757c9927fc3fde34e2abac63 (patch)
treefb50f681aced9f566da52aaf22eb4275471d010a /src/nix-env
parente6e61f0a54dac0174df996e93fcfedcac7769ab4 (diff)
OCD performance fix: {find,count}+insert => insert
Diffstat (limited to 'src/nix-env')
-rw-r--r--src/nix-env/nix-env.cc7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 87b2e43f0..48686ce72 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -124,11 +124,10 @@ static void getAllExprs(EvalState & state,
string attrName = i;
if (hasSuffix(attrName, ".nix"))
attrName = string(attrName, 0, attrName.size() - 4);
- if (attrs.find(attrName) != attrs.end()) {
+ if (!attrs.insert(attrName).second) {
printError(format("warning: name collision in input Nix expressions, skipping '%1%'") % path2);
continue;
}
- attrs.insert(attrName);
/* Load the expression on demand. */
Value & vFun = state.getBuiltin("import");
Value & vArg(*state.allocValue());
@@ -307,10 +306,8 @@ static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
/* Insert only those elements in the final list that we
haven't inserted before. */
for (auto & j : matches)
- if (done.find(j.second) == done.end()) {
- done.insert(j.second);
+ if (done.insert(j.second).second)
elems.push_back(j.first);
- }
}
checkSelectorUse(selectors);