From patchwork Thu Jun 8 19:44:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,8] bookmark: directly use base dict 'setitem' From: Pierre-Yves David X-Patchwork-Id: 21257 Message-Id: <991d87aea4949f735920.1496951063@nodosa.octopoid.net> To: mercurial-devel@mercurial-scm.org Date: Thu, 08 Jun 2017 20:44:23 +0100 # HG changeset patch # User Pierre-Yves David # Date 1496859189 -3600 # Wed Jun 07 19:13:09 2017 +0100 # Node ID 991d87aea4949f735920ef486aea59e1f727d18d # Parent b90c61451056ee0f8106b248559d48a7fb81690b # EXP-Topic perf # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 991d87aea494 bookmark: directly use base dict 'setitem' The bmstore '__setitem__' method is setting and 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) diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -52,6 +52,7 @@ class bmstore(dict): 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 @@ class bmstore(dict): 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