Prevented writing useless null tags for unstitched diverged trunks

This can happen if we end up pruning all alts in a diverged trunk.

Note this is subtly different than finding no diverged trunk, as we
still need to switch to the LFSR_D_DIVERGED* state in order to prune
alts on the non-empty diverged trunk.

We need a special case here, because there's no way to represent an
empty trunk without a reachable null tag. But a reachable null tag would
violate our rbyd's right-leaning property and break lookupnext.

We already had a special case for this situation, which would skip the
alt that would stitch the trunks together, but we were still writing out
a null tag for the diverged trunk even if it was empty.

We don't need this null tag and it turns out not writing the null tag
saves a null tag.
This commit is contained in:
Christopher Haster
2024-03-11 18:05:35 -05:00
parent 03954a1ef9
commit 9c2c5b2391
+10 -8
View File
@@ -3277,7 +3277,7 @@ again:;
}
// TODO is this not a_lower_tag?
d_tag = lfsr_tag_key(p_alts[0]);
d_tag = p_alts[0];
// flush any pending alts
err = lfsr_rbyd_p_flush(lfs, rbyd,
@@ -3290,13 +3290,15 @@ again:;
// why does hiding this behind if d_tag=0 not work?
//
// terminate diverged branch with an unreachable tag
err = lfsr_rbyd_appendattr_(lfs, rbyd,
(lfsr_rbyd_isshrub(rbyd) ? LFSR_TAG_SHRUB : 0)
| LFSR_TAG_NULL,
0,
LFSR_DATA_NULL());
if (err) {
return err;
if (d_tag) {
err = lfsr_rbyd_appendattr_(lfs, rbyd,
(lfsr_rbyd_isshrub(rbyd) ? LFSR_TAG_SHRUB : 0)
| LFSR_TAG_NULL,
0,
LFSR_DATA_NULL());
if (err) {
return err;
}
}
// save the found lower rid/tag