# HG changeset patch
# User Stanislau Hlebik <st...@fb.com>
# Date 1486981578 28800
#      Mon Feb 13 02:26:18 2017 -0800
# Node ID 8bc5ae6cf51408dbd1b789555196f031bfef19d4
# Parent  a0e3d808690d57d1c9dff840e0b8ee099526397b
localrepo: cache self.changelog in local variable

Repeated self.changelog lookups can incur overhead. Let's cache it in the
separate variable.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to