changeset 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 83e080144faf
children 067add650129
files mercurial/smartset.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/smartset.py	Mon Mar 13 08:44:57 2017 -0700
+++ b/mercurial/smartset.py	Mon Mar 13 08:53:31 2017 -0700
@@ -818,15 +818,15 @@
         # Getting rid of it would provide an about 15% speed up on this
         # iteration.
         genlist = self._genlist
-        nextrev = self._consumegen().next
-        _len = len # cache global lookup
+        nextgen = self._consumegen()
+        _len, _next = len, next # cache global lookup
         def gen():
             i = 0
             while True:
                 if i < _len(genlist):
                     yield genlist[i]
                 else:
-                    yield nextrev()
+                    yield _next(nextgen)
                 i += 1
         return gen()