1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 09:31:16 +02:00

OCD performance fix: {find,count}+insert => insert

This commit is contained in:
Eelco Dolstra 2019-10-09 15:51:52 +02:00
parent e6e61f0a54
commit 99b73fb507
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
16 changed files with 32 additions and 65 deletions

View file

@ -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);