changeset 39516:079d7bfa463d

treemanifest: attempt to avoid loading all lazily-loaded subdirs in _isempty Differential Revision: https://phab.mercurial-scm.org/D4367
author Kyle Lippincott <spectral@google.com>
date Thu, 23 Aug 2018 00:33:06 -0700
parents 93486cc46125
children 8798be5f04fc
files mercurial/manifest.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/manifest.py	Thu Aug 16 12:31:52 2018 -0700
+++ b/mercurial/manifest.py	Thu Aug 23 00:33:06 2018 -0700
@@ -726,9 +726,13 @@
 
     def _isempty(self):
         self._load() # for consistency; already loaded by all callers
+        # See if we can skip loading everything.
+        if self._files or (self._dirs and
+                           any(not m._isempty() for m in self._dirs.values())):
+            return False
         self._loadalllazy()
-        return (not self._files and (not self._dirs or
-                all(m._isempty() for m in self._dirs.values())))
+        return (not self._dirs or
+                all(m._isempty() for m in self._dirs.values()))
 
     def __repr__(self):
         return ('<treemanifest dir=%s, node=%s, loaded=%s, dirty=%s at 0x%x>' %