changeset 25146:f542a2c89b60

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sun, 17 May 2015 18:06:09 -0700
parents 3553163bb736
children fb7b9a765bb9
files mercurial/revset.py
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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]