shardtree: Compare leaves by value when merging, and merge their flags

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
This commit is contained in:
Jack Grigg 2023-07-05 21:45:56 +00:00
parent 2ef96ba4ba
commit 54e8ab759c
1 changed files with 5 additions and 2 deletions

View File

@ -218,8 +218,11 @@ impl<H: Hashable + Clone + PartialEq> PrunableTree<H> {
match (t0, t1) {
(Tree(Node::Nil), other) | (other, Tree(Node::Nil)) => Ok(other),
(Tree(Node::Leaf { value: vl }), Tree(Node::Leaf { value: vr })) => {
if vl == vr {
Ok(Tree(Node::Leaf { value: vl }))
if vl.0 == vr.0 {
// Merge the flags together.
Ok(Tree(Node::Leaf {
value: (vl.0, vl.1 | vr.1),
}))
} else {
Err(addr)
}