comparison mercurial/smartset.py @ 31446:9a94239e4f12

py3: use next() to obtain next item from inner generator of generatorset .next attribute does not exist on Python 3. As this function seems to really care about the overhead of the Python interpreter, I follow the way of micro optimization.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 13 Mar 2017 08:53:31 -0700
parents 90fb0193f187
children 413b44003462
comparison
equal deleted inserted replaced
31445:83e080144faf 31446:9a94239e4f12
816 # removed from _consumegen and added to genlist in another instance. 816 # removed from _consumegen and added to genlist in another instance.
817 # 817 #
818 # Getting rid of it would provide an about 15% speed up on this 818 # Getting rid of it would provide an about 15% speed up on this
819 # iteration. 819 # iteration.
820 genlist = self._genlist 820 genlist = self._genlist
821 nextrev = self._consumegen().next 821 nextgen = self._consumegen()
822 _len = len # cache global lookup 822 _len, _next = len, next # cache global lookup
823 def gen(): 823 def gen():
824 i = 0 824 i = 0
825 while True: 825 while True:
826 if i < _len(genlist): 826 if i < _len(genlist):
827 yield genlist[i] 827 yield genlist[i]
828 else: 828 else:
829 yield nextrev() 829 yield _next(nextgen)
830 i += 1 830 i += 1
831 return gen() 831 return gen()
832 832
833 def _consumegen(self): 833 def _consumegen(self):
834 cache = self._cache 834 cache = self._cache