diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-08-02T11·54+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2010-08-02T11·54+0000 |
commit | 7af6a2fd71e95bdc28e0015b1e89a9b81ef32711 (patch) | |
tree | 11e2f00de64f399186d6646efcbcd1bd9c2a1a71 /src/libexpr/primops.cc | |
parent | 532d766c279daf190728b4815b92f04623e7fb7f (diff) |
* intersectAttrs: optimise for the case where the second set is larger
than the first set. (That's usually the case with callPackage.)
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r-- | src/libexpr/primops.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 42c8586116aa..68f66acc74ed 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -788,13 +788,13 @@ static void prim_intersectAttrs(EvalState & state, Value * * args, Value & v) state.forceAttrs(*args[1]); 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; } } } |