revset: changed spanset __add__ implementation to work lazily
authorLucas Moscovicz <lmoscovicz@fb.com>
Thu, 13 Feb 2014 09:18:16 -0800
changeset 20587 cb18fe3461b1
parent 20586 2d52f37937b0
child 20595 710c2755e66a
revset: changed spanset __add__ implementation to work lazily $ time hg log -qr "first(0:tip or draft())" ... real 0m1.032s user 0m0.841s sys 0m0.179s $ time ./hg log -qr "first(0:tip or draft())" ... real 0m0.378s user 0m0.291s sys 0m0.085s
mercurial/revset.py
--- a/mercurial/revset.py	Thu Feb 13 09:00:25 2014 -0800
+++ b/mercurial/revset.py	Thu Feb 13 09:18:16 2014 -0800
@@ -2311,8 +2311,14 @@
         return lazyset(self, lambda r: r not in x)
 
     def __add__(self, x):
-        l = baseset(self)
-        return l + baseset(x)
+        def iterates():
+            for r in self:
+                yield r
+            for r in x:
+                if r not in self:
+                    yield r
+
+        return lazyset(generatorset(iterates()))
 
     def __len__(self):
         if not self._hiddenrevs: