discovery: simplify the building of the children mapping
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 05 Mar 2019 15:39:54 +0100
changeset 41888 1f069f37e601
parent 41887 c98420914c10
child 41889 d5e6ae6e8012
discovery: simplify the building of the children mapping Since we only care about the revisions inside the set we are sampling, we can use simpler code (and probably sightly faster).
mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py	Tue Mar 05 15:52:14 2019 +0100
+++ b/mercurial/setdiscovery.py	Tue Mar 05 15:39:54 2019 +0100
@@ -219,13 +219,13 @@
         for rev in sorted(revs):
             # Always ensure revision has an entry so we don't need to worry
             # about missing keys.
-            children.setdefault(rev, [])
-
+            children[rev] = []
             for prev in parentrevs(rev):
                 if prev == nullrev:
                     continue
-
-                children.setdefault(prev, []).append(rev)
+                c = children.get(prev)
+                if c is not None:
+                    c.append(rev)
 
         _updatesample(revs, revsroots, sample, children.__getitem__)
         assert sample