diff mercurial/changelog.py @ 17951:6f79c32c0bdf stable

commit: increase perf by avoiding unnecessary filteredrevs check When commiting to a repo with lots of history (>400000 changesets) the filteredrevs check (added with 5c89e7fa5bc2) in changelog.py takes a bit of time even if the filteredrevs set is empty. Skipping the check in that case shaves 0.36 seconds off a 2.14 second commit. A 17% gain.
author Durham Goode <durham@fb.com>
date Fri, 16 Nov 2012 15:39:12 -0800
parents 2894d180afa1
children c0c943ef4e55
line wrap: on
line diff
--- a/mercurial/changelog.py	Thu Nov 15 11:27:30 2012 -0600
+++ b/mercurial/changelog.py	Fri Nov 16 15:39:12 2012 -0800
@@ -134,9 +134,15 @@
 
     def __iter__(self):
         """filtered version of revlog.__iter__"""
-        for i in xrange(len(self)):
-            if i not in self.filteredrevs:
-                yield i
+        if len(self.filteredrevs) == 0:
+            return revlog.revlog.__iter__(self)
+
+        def filterediter():
+            for i in xrange(len(self)):
+                if i not in self.filteredrevs:
+                    yield i
+
+        return filterediter()
 
     def revs(self, start=0, stop=None):
         """filtered version of revlog.revs"""