1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

* intersectAttrs: optimise for the case where the second set is larger

than the first set.  (That's usually the case with callPackage.)
This commit is contained in:
Eelco Dolstra 2010-08-02 11:54:44 +00:00
parent 532d766c27
commit 7af6a2fd71

View file

@ -789,12 +789,12 @@ static void prim_intersectAttrs(EvalState & state, Value * * args, Value & v)
state.mkAttrs(v);
foreach (Bindings::iterator, i, *args[1]->attrs) {
Bindings::iterator j = args[0]->attrs->find(i->first);
if (j != args[0]->attrs->end()) {
Attr & a = (*v.attrs)[i->first];
mkCopy(a.value, i->second.value);
a.pos = i->second.pos;
foreach (Bindings::iterator, i, *args[0]->attrs) {
Bindings::iterator j = args[1]->attrs->find(i->first);
if (j != args[1]->attrs->end()) {
Attr & a = (*v.attrs)[j->first];
mkCopy(a.value, j->second.value);
a.pos = j->second.pos;
}
}
}