changeset 32737:d6924192c0d5

bookmarks: directly use base dict 'setitem' The bmstore '__setitem__' method is setting an extra flag that is not needed during initialization. Skipping the method will allow further cleanup and yield some speedup as a side effect. Before: ! wall 0.009120 comb 0.010000 user 0.010000 sys 0.000000 (best of 312) After: ! wall 0.007874 comb 0.010000 user 0.010000 sys 0.000000 (best of 360)
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 07 Jun 2017 19:13:09 +0100
parents 173f1bdc322d
children 999aa9cfb4d3
files mercurial/bookmarks.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Wed Jun 07 19:22:39 2017 +0100
+++ b/mercurial/bookmarks.py	Wed Jun 07 19:13:09 2017 +0100
@@ -52,6 +52,7 @@
         self._repo = repo
         nm = repo.changelog.nodemap
         tonode = bin # force local lookup
+        setitem = dict.__setitem__
         try:
             bkfile = _getbkfile(repo)
             for line in bkfile:
@@ -63,7 +64,7 @@
                     node = tonode(sha)
                     if node in nm:
                         refspec = encoding.tolocal(refspec)
-                        self[refspec] = node
+                        setitem(self, refspec, node)
                 except (TypeError, ValueError):
                     # - bin(...) can raise TypeError
                     # - node in nm can raise ValueError for non-20-bytes entry