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