manifest: check 'if x is None' instead of 'if not x'
authorDurham Goode <durham@fb.com>
Sun, 26 Feb 2017 10:16:47 -0800
changeset 31097 4a1486c73fdf
parent 31096 356937ea7a02
child 31098 876f08f30ade
manifest: check 'if x is None' instead of 'if not x' The old code here would end up executing __len__ on a tree manifest to determine if 'not _data' was true or not. This was very expensive on large repos. Since this function just cares about memoization, we can just check 'if _data is None' instead and save a bunch of time.
mercurial/manifest.py
--- a/mercurial/manifest.py	Sat Feb 25 03:42:43 2017 +0530
+++ b/mercurial/manifest.py	Sun Feb 26 10:16:47 2017 -0800
@@ -1386,7 +1386,7 @@
         return self._revlog().parents(self._node)
 
     def read(self):
-        if not self._data:
+        if self._data is None:
             if self._node == revlog.nullid:
                 self._data = manifestdict()
             else:
@@ -1484,7 +1484,7 @@
         return self._repo.manifestlog._revlog.dirlog(self._dir)
 
     def read(self):
-        if not self._data:
+        if self._data is None:
             rl = self._revlog()
             if self._node == revlog.nullid:
                 self._data = treemanifest()