1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 15:51:15 +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

@ -396,8 +396,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
throw EvalError(format("attribute 'key' required, at %1%") % pos);
state.forceValue(*key->value);
if (doneKeys.find(key->value) != doneKeys.end()) continue;
doneKeys.insert(key->value);
if (!doneKeys.insert(key->value).second) continue;
res.push_back(e);
/* Call the `operator' function with `e' as argument. */
@ -1273,13 +1272,12 @@ static void prim_listToAttrs(EvalState & state, const Pos & pos, Value * * args,
string name = state.forceStringNoCtx(*j->value, pos);
Symbol sym = state.symbols.create(name);
if (seen.find(sym) == seen.end()) {
if (seen.insert(sym).second) {
Bindings::iterator j2 = v2.attrs->find(state.symbols.create(state.sValue));
if (j2 == v2.attrs->end())
throw TypeError(format("'value' attribute missing in a call to 'listToAttrs', at %1%") % pos);
v.attrs->push_back(Attr(sym, j2->value, j2->pos));
seen.insert(sym);
}
}