addset: offer a fastasc and fastdesc methods
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 02 Oct 2014 23:38:30 -0500
changeset 22742 6bbc26adcc6a
parent 22741 ef2c1ea8fb2c
child 22743 eccf9907b844
addset: offer a fastasc and fastdesc methods If the underlying object offers fast iterators, we use them to provide fast iterators too.
mercurial/revset.py
--- a/mercurial/revset.py	Thu Oct 02 23:28:18 2014 -0500
+++ b/mercurial/revset.py	Thu Oct 02 23:38:30 2014 -0500
@@ -2659,6 +2659,22 @@
             return iter(self._genlist)
         return iter(self._iterator())
 
+    @property
+    def fastasc(self):
+        iter1 = self._r1.fastasc
+        iter2 = self._r2.fastasc
+        if None in (iter1, iter2):
+            return None
+        return lambda: self._iterordered(True, iter1(), iter2())
+
+    @property
+    def fastdesc(self):
+        iter1 = self._r1.fastdesc
+        iter2 = self._r2.fastdesc
+        if None in (iter1, iter2):
+            return None
+        return lambda: self._iterordered(False, iter1(), iter2())
+
     def _iterordered(self, ascending, iter1, iter2):
         """produce an ordered iteration from two iterators with the same order