Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 22742:6bbc26adcc6a
addset: offer a fastasc and fastdesc methods
If the underlying object offers fast iterators, we use them to provide fast
iterators too.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 02 Oct 2014 23:38:30 -0500 |
parents | ef2c1ea8fb2c |
children | eccf9907b844 |
comparison
equal
deleted
inserted
replaced
22741:ef2c1ea8fb2c | 22742:6bbc26adcc6a |
---|---|
2657 def __iter__(self): | 2657 def __iter__(self): |
2658 if self._genlist: | 2658 if self._genlist: |
2659 return iter(self._genlist) | 2659 return iter(self._genlist) |
2660 return iter(self._iterator()) | 2660 return iter(self._iterator()) |
2661 | 2661 |
2662 @property | |
2663 def fastasc(self): | |
2664 iter1 = self._r1.fastasc | |
2665 iter2 = self._r2.fastasc | |
2666 if None in (iter1, iter2): | |
2667 return None | |
2668 return lambda: self._iterordered(True, iter1(), iter2()) | |
2669 | |
2670 @property | |
2671 def fastdesc(self): | |
2672 iter1 = self._r1.fastdesc | |
2673 iter2 = self._r2.fastdesc | |
2674 if None in (iter1, iter2): | |
2675 return None | |
2676 return lambda: self._iterordered(False, iter1(), iter2()) | |
2677 | |
2662 def _iterordered(self, ascending, iter1, iter2): | 2678 def _iterordered(self, ascending, iter1, iter2): |
2663 """produce an ordered iteration from two iterators with the same order | 2679 """produce an ordered iteration from two iterators with the same order |
2664 | 2680 |
2665 The ascending is used to indicated the iteration direction. | 2681 The ascending is used to indicated the iteration direction. |
2666 """ | 2682 """ |