Mercurial > hg-stable
changeset 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 |
files | mercurial/revset.py |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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