# HG changeset patch # User David Soria Parra # Date 2017-11-23 22:13:14 # Node ID 8287df8b7be545fdafa22b771012ac65f6264d12 # Parent ec25c8275cfaac673ccb9e1ac22d0c554b9fe672 hbisect: use a defaultdict to avoid large allocations for a large changelogs We can avoid a SPACE(len(changelog)) allocation by using a defaultdict. Test Plan: python run-tests.py test-bisect* Differential Revision: https://phab.mercurial-scm.org/D1499 diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py --- a/mercurial/hbisect.py +++ b/mercurial/hbisect.py @@ -38,7 +38,7 @@ def bisect(repo, state): def buildancestors(bad, good): badrev = min([changelog.rev(n) for n in bad]) - ancestors = [None] * (len(changelog) + 1) + ancestors = collections.defaultdict(lambda: None) for rev in repo.revs("descendants(%ln) - ancestors(%ln)", good, good): ancestors[rev] = [] if ancestors[badrev] is None: