# HG changeset patch # User Pierre-Yves David # Date 1496968782 -3600 # Node ID 86959f2c625de8f9ea84077eb08d9ab902b5be67 # Parent 427f6091250e17f9e6ca47c277983d6903ed4c5a 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. diff -r 427f6091250e -r 86959f2c625d hgext3rd/evolve/obscache.py --- a/hgext3rd/evolve/obscache.py Fri Jun 09 01:26:29 2017 +0100 +++ b/hgext3rd/evolve/obscache.py Fri Jun 09 01:39:42 2017 +0100 @@ -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"""