localrepo: cache self.changelog in local variable
authorStanislau Hlebik <stash@fb.com>
Mon, 13 Feb 2017 02:26:18 -0800
changeset 30905 6037caa6a2f3
parent 30904 76a1e735449c
child 30906 72f25e17af9d
localrepo: cache self.changelog in local variable Repeated self.changelog lookups can incur overhead. Let's cache it in the separate variable.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Feb 07 13:11:30 2017 -0800
+++ b/mercurial/localrepo.py	Mon Feb 13 02:26:18 2017 -0800
@@ -1853,8 +1853,9 @@
 
     def heads(self, start=None):
         if start is None:
-            headrevs = sorted(self.changelog.headrevs(), reverse=True)
-            return [self.changelog.node(rev) for rev in headrevs]
+            cl = self.changelog
+            headrevs = sorted(cl.headrevs(), reverse=True)
+            return [cl.node(rev) for rev in headrevs]
 
         heads = self.changelog.heads(start)
         # sort the output in rev descending order