Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.1 on 2022-01-26 at 16:00 UTC+1 (a few minutes of down time)

Commit 6e408f19 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

dagop: simplify dict/set reuse condition in subsetparentswalker

Prepares for fixing the calculation of p1/p2 sort keys.

With this change, there will be one more copying on merge&fork case. I think
the copying cost is negligible since we'll have to update each item in the
dict on merge/fork.
parent 843418dc0b1b
......@@ -449,12 +449,18 @@ class subsetparentswalker(object):
# - one of the parents is not active,
# - or descendants' parents are unresolved.
if not bothparentsactive or unresolved or resolved:
if len(parentrevs) > 1:
if len(parentrevs) <= 1:
# can avoid copying the tracking pointer
parentpointers = [(unresolved, resolved)]
else:
parentpointers = [
(unresolved, resolved),
(unresolved.copy(), resolved.copy()),
]
# 'rev' is a merge revision. increment the pending count
# as the 'unresolved' dict will be duplicated.
for r in unresolved:
pendingcnt[r] += 1
reusable = True # can we avoid copying the tracking pointer?
for i, p in enumerate(parentrevs):
assert p < rev
heapq.heappush(tovisit, -p)
......@@ -462,6 +468,7 @@ class subsetparentswalker(object):
# 'p' is a fork revision. concatenate tracking pointers
# and decrement the pending count accordingly.
knownunresolved, knownresolved = pointers[p]
unresolved, resolved = parentpointers[i]
for r, c in unresolved.items():
c += [b'1', b'2'][i]
if r in knownunresolved:
......@@ -475,11 +482,8 @@ class subsetparentswalker(object):
# simply propagate the 'resolved' set as deduplicating
# 'unresolved' here would be slightly complicated.
knownresolved.update(resolved)
elif reusable:
pointers[p] = (unresolved, resolved)
reusable = False
else:
pointers[p] = (unresolved.copy(), resolved.copy())
pointers[p] = parentpointers[i]
# then, populate the active parents directly and add the current
# 'rev' to the tracking pointers of the inactive parents.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment