Fix two canonicalization bugs

This commit is contained in:
2024-06-14 21:51:59 -07:00
parent a63fd3970b
commit e4a77c88d8

View File

@@ -961,6 +961,8 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
remove(iter);
insert(keyAfter({m.param1, m.param1Len}, arena), {},
/*endRange*/ true, iter);
} else if (engulfRight) {
insert({m.param1, m.param1Len}, {}, /*endRange*/ false, iter);
} else {
insert({m.param1, m.param1Len}, {{nullptr, -1}}, /*endRange*/ false,
iter);
@@ -992,12 +994,15 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
}
// Check if we can engulf on the right
end.copyTo(copy);
move<std::memory_order_relaxed, true>(copy, latestVersion);
const auto *next = copy.searchPathSize() > 0
? mm.base[copy.backNode()].entry
: nullptr;
const bool engulfRight = next && next->clearTo();
bool engulfRight = false;
if (!foundEnd) {
end.copyTo(copy);
move<std::memory_order_relaxed, true>(copy, latestVersion);
const auto *next = copy.searchPathSize() > 0
? mm.base[copy.backNode()].entry
: nullptr;
engulfRight = next && next->clearTo();
}
if (engulfLeft && foundBegin) {
remove(begin);