generatorset: use 'next()' to simplify the code
authorPierre-Yves David <pierre-yves.david@fb.com>
Sun, 17 May 2015 18:06:09 -0700
changeset 25146 f542a2c89b60
parent 25145 3553163bb736
child 25147 fb7b9a765bb9
generatorset: use 'next()' to simplify the code The 'next()' built-in accept a default value. This remove the needs to check if self non-empty before returning a value.
mercurial/revset.py
--- a/mercurial/revset.py	Sun May 17 18:00:38 2015 -0700
+++ b/mercurial/revset.py	Sun May 17 18:06:09 2015 -0700
@@ -3322,9 +3322,7 @@
             for x in self._consumegen():
                 pass
             return self.first()
-        if self:
-            return it().next()
-        return None
+        return next(it(), None)
 
     def last(self):
         if self._ascending:
@@ -3336,9 +3334,7 @@
             for x in self._consumegen():
                 pass
             return self.first()
-        if self:
-            return it().next()
-        return None
+        return next(it(), None)
 
     def __repr__(self):
         d = {False: '-', True: '+'}[self._ascending]