baseset: prepare lazy ordering in __iter__
We'll explicitly track the order of the baseset to take advantage of the
ascending and descending lists during iteration.
--- a/mercurial/revset.py Fri Oct 03 03:19:23 2014 -0500
+++ b/mercurial/revset.py Fri Oct 03 03:26:18 2014 -0500
@@ -2331,6 +2331,7 @@
data = list(data)
self._list = data
self._set = None
+ self._ascending = None
@util.propertycache
def _asclist(self):
@@ -2338,6 +2339,14 @@
asclist.sort()
return asclist
+ def __iter__(self):
+ if self._ascending is None:
+ return iter(self._list)
+ elif self._ascending:
+ return iter(self._asclist)
+ else:
+ return reversed(self._asclist)
+
def fastasc(self):
return iter(self._asclist)
@@ -2368,9 +2377,6 @@
def reverse(self):
self._list.reverse()
- def __iter__(self):
- return iter(self._list)
-
def __len__(self):
return len(self._list)