Mercurial > public > mercurial-scm > hg-stable
diff mercurial/scmutil.py @ 40492:597bb5a6867f
filecache: use try-except for faster __dict__ lookup
Python function call is slow, and the cost could be significant here.
$ hg perfrevset 'branch(tip)' -R mercurial
(orig) wall 0.139511 comb 0.140000 user 0.140000 sys 0.000000 (best of 66)
(this) wall 0.114195 comb 0.110000 user 0.110000 sys 0.000000 (best of 81)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 20 Oct 2018 19:13:05 +0900 |
parents | bf249bb60087 |
children | 7caf632e30c3 |
line wrap: on
line diff
--- a/mercurial/scmutil.py Thu Oct 18 19:57:30 2018 -0700 +++ b/mercurial/scmutil.py Sat Oct 20 19:13:05 2018 +0900 @@ -1292,9 +1292,10 @@ if obj is None: return self # do we need to check if the file changed? - if self.sname in obj.__dict__: - assert self.name in obj._filecache, self.name + try: return obj.__dict__[self.sname] + except KeyError: + pass entry = obj._filecache.get(self.name)