D4149: linelog: extract `len(self._program)` to a local function
quark (Jun Wu)
phabricator at mercurial-scm.org
Tue Aug 7 02:00:05 UTC 2018
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This is a micro optimization prepared for following changes where
`len(self._program)` is used in a loop.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D4149
AFFECTED FILES
mercurial/linelog.py
CHANGE DETAILS
diff --git a/mercurial/linelog.py b/mercurial/linelog.py
--- a/mercurial/linelog.py
+++ b/mercurial/linelog.py
@@ -296,6 +296,7 @@
else:
ar = self.annotate(rev)
# ar = self.annotate(self._maxrev)
+ programlen = self._program.__len__
if a1 > len(ar.lines):
raise LineLogError(
'%d contains %d lines, tried to access line %d' % (
@@ -308,7 +309,7 @@
else:
a1info = ar.lines[a1]
a1inst = self._program[a1info._offset]
- oldproglen = len(self._program)
+ oldproglen = programlen()
appendinst = self._program.append
# insert
To: quark, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list