diff mercurial/hbisect.py @ 35130:8287df8b7be5

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
author David Soria Parra <davidsp@fb.com>
date Thu, 23 Nov 2017 14:13:14 -0800
parents ec25c8275cfa
children 80da79b6fbe4
line wrap: on
line diff
--- a/mercurial/hbisect.py	Thu Nov 23 14:12:55 2017 -0800
+++ b/mercurial/hbisect.py	Thu Nov 23 14:13:14 2017 -0800
@@ -38,7 +38,7 @@
 
     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: