changeset 2666:86959f2c625d

obscache: directly allocate zeroed bytearray This is much faster that incrementally appending to it. On mozilla central without obsolescence markers this move full cache building from 0.3s to nothing visible.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 09 Jun 2017 01:39:42 +0100
parents 427f6091250e
children 3f469be5f3a7
files hgext3rd/evolve/obscache.py
diffstat 1 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/obscache.py
+++ b/hgext3rd/evolve/obscache.py
@@ -417,16 +417,18 @@
         For now we stick to the simpler approach of paying the
         performance cost on new changesets.
         """
-        node = repo.changelog.node
-        succs = repo.obsstore.successors
-        for r in revs:
-            if node(r) in succs:
-                val = 1
-            else:
-                val = 0
-            self._data.append(val)
-        cl = repo.changelog
-        assert len(self._data) == len(cl), (len(self._data), len(cl))
+        new_entries = bytearray(len(revs))
+        if not self._data:
+            self._setdata(new_entries)
+        else:
+            self._data.extend(new_entries)
+        data = self._data
+        if repo.obsstore:
+            node = repo.changelog.node
+            succs = repo.obsstore.successors
+            for r in revs:
+                if node(r) in succs:
+                    data[r] = 1
 
     def _updatemarkers(self, repo, obsmarkers):
         """update the cache with new markers"""