about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-08-02T16·31+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-08-02T16·31+0000
commit6d6200f37afe10e8da3b08582a926245538af5d6 (patch)
tree7a01dde5023f9825b404d88d33a3709908b1144a /src/libexpr/eval.cc
parent7af6a2fd71e95bdc28e0015b1e89a9b81ef32711 (diff)
* Optimisation in the // operator: if one of the sets is empty, return
  the other set.

Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index eb1d8d432c69..96bda43a322a 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -750,13 +750,15 @@ void ExprOpImpl::eval(EvalState & state, Env & env, Value & v)
 
 void ExprOpUpdate::eval(EvalState & state, Env & env, Value & v)
 {
-    Value v2;
-    state.evalAttrs(env, e1, v2);
-        
-    state.cloneAttrs(v2, v);
-        
+    Value v1, v2;
+    state.evalAttrs(env, e1, v1);
     state.evalAttrs(env, e2, v2);
-    
+
+    if (v1.attrs->size() == 0) { v = v2; return; }
+    if (v2.attrs->size() == 0) { v = v1; return; }
+
+    state.cloneAttrs(v1, v);
+
     foreach (Bindings::iterator, i, *v2.attrs) {
         Attr & a = (*v.attrs)[i->first];
         mkCopy(a.value, i->second.value);