changeset 32734:b5613bda454e

bookmarks: prefetch 'lookup' outside of the loop Skipping the attribute lookup up raise a significant speedup. Example on a repository with about 4000 bookmarks. Before: ! wall 0.026027 comb 0.020000 user 0.020000 sys 0.000000 (best of 112) After: ! wall 0.021580 comb 0.020000 user 0.020000 sys 0.000000 (best of 134) (This is also in its own changeset to clarify the perf win from another coming changesets)
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 07 Jun 2017 19:21:02 +0100
parents 2b0a8b0f3435
children d7522f983f37
files mercurial/bookmarks.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Jun 07 18:22:11 2017 +0100
+++ b/mercurial/bookmarks.py	Wed Jun 07 19:21:02 2017 +0100
@@ -50,6 +50,7 @@
     def __init__(self, repo):
         dict.__init__(self)
         self._repo = repo
+        lookup = repo.changelog.lookup
         try:
             bkfile = _getbkfile(repo)
             for line in bkfile:
@@ -63,7 +64,7 @@
                 sha, refspec = line.split(' ', 1)
                 refspec = encoding.tolocal(refspec)
                 try:
-                    self[refspec] = repo.changelog.lookup(sha)
+                    self[refspec] = lookup(sha)
                 except LookupError:
                     pass
         except IOError as inst: