forked from lix-project/lix
* 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:
parent
532d766c27
commit
7af6a2fd71
|
@ -788,13 +788,13 @@ static void prim_intersectAttrs(EvalState & state, Value * * args, Value & v)
|
||||||
state.forceAttrs(*args[1]);
|
state.forceAttrs(*args[1]);
|
||||||
|
|
||||||
state.mkAttrs(v);
|
state.mkAttrs(v);
|
||||||
|
|
||||||
foreach (Bindings::iterator, i, *args[1]->attrs) {
|
foreach (Bindings::iterator, i, *args[0]->attrs) {
|
||||||
Bindings::iterator j = args[0]->attrs->find(i->first);
|
Bindings::iterator j = args[1]->attrs->find(i->first);
|
||||||
if (j != args[0]->attrs->end()) {
|
if (j != args[1]->attrs->end()) {
|
||||||
Attr & a = (*v.attrs)[i->first];
|
Attr & a = (*v.attrs)[j->first];
|
||||||
mkCopy(a.value, i->second.value);
|
mkCopy(a.value, j->second.value);
|
||||||
a.pos = i->second.pos;
|
a.pos = j->second.pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue