Tidy
This commit is contained in:
@@ -247,10 +247,10 @@ void lastLeqMulti(Node *root, std::span<Key> keys, Iterator *results) {
|
|||||||
fprintf(file, "\n");
|
fprintf(file, "\n");
|
||||||
for (auto iter = extrema(node, false); iter != nullptr;
|
for (auto iter = extrema(node, false); iter != nullptr;
|
||||||
iter = next(iter, true)) {
|
iter = next(iter, true)) {
|
||||||
fprintf(file, " k_%.*s [label=\"k=%.*s;m=%d;v=%d,r=%d\"];\n", iter->len,
|
fprintf(file, " k_%.*s [label=\"k=\\\"%.*s\\\" m=%d v=%d r=%d\"];\n",
|
||||||
(const char *)(iter + 1), iter->len, (const char *)(iter + 1),
|
iter->len, (const char *)(iter + 1), iter->len,
|
||||||
int(iter->maxVersion), int(iter->pointVersion),
|
(const char *)(iter + 1), int(iter->maxVersion),
|
||||||
int(iter->rangeVersion));
|
int(iter->pointVersion), int(iter->rangeVersion));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < printer.id; ++i) {
|
for (int i = 0; i < printer.id; ++i) {
|
||||||
fprintf(file, " null%d [shape=point];\n", i);
|
fprintf(file, " null%d [shape=point];\n", i);
|
||||||
@@ -357,7 +357,6 @@ struct ConflictSet::Impl {
|
|||||||
Node **current = &root;
|
Node **current = &root;
|
||||||
Node *parent = nullptr;
|
Node *parent = nullptr;
|
||||||
const auto &key = write.begin;
|
const auto &key = write.begin;
|
||||||
bool inserted = false;
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (*current == nullptr) {
|
if (*current == nullptr) {
|
||||||
auto *newNode = createNode(key, parent, write.writeVersion);
|
auto *newNode = createNode(key, parent, write.writeVersion);
|
||||||
@@ -366,7 +365,6 @@ struct ConflictSet::Impl {
|
|||||||
assert(prev != nullptr);
|
assert(prev != nullptr);
|
||||||
assert(prev->rangeVersion <= write.writeVersion);
|
assert(prev->rangeVersion <= write.writeVersion);
|
||||||
newNode->rangeVersion = prev->rangeVersion;
|
newNode->rangeVersion = prev->rangeVersion;
|
||||||
inserted = true;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// This is the key optimization - setting the max version on the way
|
// This is the key optimization - setting the max version on the way
|
||||||
@@ -382,27 +380,26 @@ struct ConflictSet::Impl {
|
|||||||
current = &((*current)->child[c > 0]);
|
current = &((*current)->child[c > 0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (inserted) {
|
|
||||||
auto *n = *current;
|
auto *n = *current;
|
||||||
assert(n != nullptr);
|
assert(n != nullptr);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (n->parent == nullptr) {
|
if (n->parent == nullptr) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const bool dir = n == n->parent->child[1];
|
const bool dir = n == n->parent->child[1];
|
||||||
assert(dir || n == n->parent->child[0]);
|
assert(dir || n == n->parent->child[0]);
|
||||||
// p is the address of the pointer to n->parent in the tree
|
// p is the address of the pointer to n->parent in the tree
|
||||||
Node **p = n->parent->parent == nullptr
|
Node **p = n->parent->parent == nullptr
|
||||||
? &root
|
? &root
|
||||||
: &n->parent->parent
|
: &n->parent->parent
|
||||||
->child[n->parent->parent->child[1] == n->parent];
|
->child[n->parent->parent->child[1] == n->parent];
|
||||||
assert(*p == n->parent);
|
assert(*p == n->parent);
|
||||||
if (n->parent->priority < n->priority) {
|
if (n->parent->priority < n->priority) {
|
||||||
p = rotate(p, !dir);
|
p = rotate(p, !dir);
|
||||||
n = (*p)->parent;
|
n = (*p)->parent;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,12 +462,13 @@ ConflictSet &ConflictSet::operator=(ConflictSet &&other) noexcept {
|
|||||||
|
|
||||||
#ifdef ENABLE_TESTS
|
#ifdef ENABLE_TESTS
|
||||||
int main(void) {
|
int main(void) {
|
||||||
ConflictSet::Impl cs{0};
|
int64_t writeVersion = 0;
|
||||||
|
ConflictSet::Impl cs{writeVersion};
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
ConflictSet::WriteRange write;
|
ConflictSet::WriteRange write;
|
||||||
write.begin = toKey(i);
|
write.begin = toKey(i);
|
||||||
write.end.len = 0;
|
write.end.len = 0;
|
||||||
write.writeVersion = i;
|
write.writeVersion = ++writeVersion;
|
||||||
cs.addWrites(&write, 1);
|
cs.addWrites(&write, 1);
|
||||||
}
|
}
|
||||||
debugPrintDot(stdout, cs.root);
|
debugPrintDot(stdout, cs.root);
|
||||||
|
Reference in New Issue
Block a user