Skip to content

Commit

Permalink
fixup remove
Browse files Browse the repository at this point in the history
  • Loading branch information
sears committed Apr 23, 2020
1 parent ee8eb8f commit 675eb75
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions fdbclient/VersionedMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,16 @@ namespace PTreeImpl {
void remove(Reference<PTree<T>>& p, Version at, const X& x) {
if (!p) ASSERT(false); // attempt to remove item not present in PTree
comparison cmp = compare(x, p->data);
if (cmp == 0) {
removeRoot(p, at);
} else {
Reference<PTree<T>> child = p->child(cmp > 0, at);
if (cmp < 0) {
Reference<PTree<T>> child = p->child(0, at);
remove(child, at, x);
p = update(p, 0, child, at);
} else if (cmp > 0) {
Reference<PTree<T>> child = p->child(1, at);
remove(child, at, x);
p = update(p, cmp > 0, child, at);
p = update(p, 1, child, at);
} else {
removeRoot(p, at);
}
}

Expand Down

0 comments on commit 675eb75

Please sign in to comment.