Rotate all the way to the bottom for simplicity
This commit is contained in:
@@ -822,7 +822,6 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
|||||||
|
|
||||||
// True if finger is pointing to an entry > than the entry we're removing
|
// True if finger is pointing to an entry > than the entry we're removing
|
||||||
// after we rotate it down
|
// after we rotate it down
|
||||||
bool greaterThan;
|
|
||||||
|
|
||||||
// Rotate down until we can remove the entry
|
// Rotate down until we can remove the entry
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -831,17 +830,13 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
|||||||
child<std::memory_order_relaxed>(node, false, latestVersion);
|
child<std::memory_order_relaxed>(node, false, latestVersion);
|
||||||
const auto r =
|
const auto r =
|
||||||
child<std::memory_order_relaxed>(node, true, latestVersion);
|
child<std::memory_order_relaxed>(node, true, latestVersion);
|
||||||
if (l == 0) {
|
if (l == 0 && r == 0) {
|
||||||
node = r;
|
// TODO we can avoid some rotations if we stop when l or r == 0
|
||||||
greaterThan = true;
|
node = 0;
|
||||||
break;
|
|
||||||
} else if (r == 0) {
|
|
||||||
node = l;
|
|
||||||
greaterThan = false;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
const bool direction =
|
const bool direction = (l == 0 ? 0 : mm.base[l].entry->priority) >
|
||||||
mm.base[l].entry->priority > mm.base[r].entry->priority;
|
(r == 0 ? 0 : mm.base[r].entry->priority);
|
||||||
rotate(node, latestVersion, direction);
|
rotate(node, latestVersion, direction);
|
||||||
assert(node != 0);
|
assert(node != 0);
|
||||||
finger.push(
|
finger.push(
|
||||||
@@ -853,7 +848,8 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
|||||||
// propagate up the search path, all the way to the root since we may have
|
// propagate up the search path, all the way to the root since we may have
|
||||||
// more rotations to do even if an update doesn't change a node pointer
|
// more rotations to do even if an update doesn't change a node pointer
|
||||||
auto node = finger.backNode();
|
auto node = finger.backNode();
|
||||||
const auto oldSize = finger.searchPathSize() - (node == 0);
|
assert(node == 0);
|
||||||
|
const auto oldSize = finger.searchPathSize();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (finger.searchPathSize() == 1) {
|
if (finger.searchPathSize() == 1) {
|
||||||
// Made it to the root
|
// Made it to the root
|
||||||
@@ -869,18 +865,8 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl {
|
|||||||
}
|
}
|
||||||
finger.setSearchPathSizeUnsafe(oldSize);
|
finger.setSearchPathSizeUnsafe(oldSize);
|
||||||
|
|
||||||
if (greaterThan && finger.backNode() != 0) {
|
// finger now points to the insertion point of the node we're removing
|
||||||
uint32_t c;
|
move<std::memory_order_relaxed>(finger, latestVersion, true);
|
||||||
while ((c = child<std::memory_order_relaxed>(finger.backNode(), false,
|
|
||||||
latestVersion)) != 0) {
|
|
||||||
finger.push(c, false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
while (finger.searchPathSize() > 1 && finger.backDirection() == true) {
|
|
||||||
finger.pop();
|
|
||||||
}
|
|
||||||
finger.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (finger.searchPathSize() > 0) {
|
if (finger.searchPathSize() > 0) {
|
||||||
|
Reference in New Issue
Block a user