Move addWriteRange into its own function
This commit is contained in:
@@ -1393,35 +1393,10 @@ void destroyTree(Node *root) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
void addWriteRange(Node *&root, int64_t oldestVersion,
|
||||||
|
const ConflictSet::WriteRange &w) {
|
||||||
|
|
||||||
void check(const ReadRange *reads, Result *result, int count) const {
|
auto *begin = insert(&root, std::span<const uint8_t>(w.begin.p, w.begin.len),
|
||||||
Arena arena{64 << 10};
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
result[i] =
|
|
||||||
reads[i].readVersion < oldestVersion ? TooOld
|
|
||||||
: (reads[i].end.len > 0
|
|
||||||
? checkRangeRead(root,
|
|
||||||
std::span<const uint8_t>(reads[i].begin.p,
|
|
||||||
reads[i].begin.len),
|
|
||||||
std::span<const uint8_t>(reads[i].end.p,
|
|
||||||
reads[i].end.len),
|
|
||||||
reads[i].readVersion)
|
|
||||||
: checkPointRead(root,
|
|
||||||
std::span<const uint8_t>(reads[i].begin.p,
|
|
||||||
reads[i].begin.len),
|
|
||||||
reads[i].readVersion))
|
|
||||||
? Commit
|
|
||||||
: Conflict;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void addWrites(const WriteRange *writes, int count) {
|
|
||||||
for (int i = 0; i < count; ++i) {
|
|
||||||
const auto &w = writes[i];
|
|
||||||
if (w.end.len > 0) {
|
|
||||||
auto *begin =
|
|
||||||
insert(&root, std::span<const uint8_t>(w.begin.p, w.begin.len),
|
|
||||||
w.writeVersion, true);
|
w.writeVersion, true);
|
||||||
|
|
||||||
const bool insertedBegin = !std::exchange(begin->entryPresent, true);
|
const bool insertedBegin = !std::exchange(begin->entryPresent, true);
|
||||||
@@ -1466,6 +1441,36 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
|||||||
eraseChild(old->parent, old->parentsIndex);
|
eraseChild(old->parent, old->parentsIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct __attribute__((visibility("hidden"))) ConflictSet::Impl {
|
||||||
|
|
||||||
|
void check(const ReadRange *reads, Result *result, int count) const {
|
||||||
|
Arena arena{64 << 10};
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
result[i] =
|
||||||
|
reads[i].readVersion < oldestVersion ? TooOld
|
||||||
|
: (reads[i].end.len > 0
|
||||||
|
? checkRangeRead(root,
|
||||||
|
std::span<const uint8_t>(reads[i].begin.p,
|
||||||
|
reads[i].begin.len),
|
||||||
|
std::span<const uint8_t>(reads[i].end.p,
|
||||||
|
reads[i].end.len),
|
||||||
|
reads[i].readVersion)
|
||||||
|
: checkPointRead(root,
|
||||||
|
std::span<const uint8_t>(reads[i].begin.p,
|
||||||
|
reads[i].begin.len),
|
||||||
|
reads[i].readVersion))
|
||||||
|
? Commit
|
||||||
|
: Conflict;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void addWrites(const WriteRange *writes, int count) {
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
const auto &w = writes[i];
|
||||||
|
if (w.end.len > 0) {
|
||||||
|
addWriteRange(root, oldestVersion, w);
|
||||||
} else {
|
} else {
|
||||||
auto *n =
|
auto *n =
|
||||||
insert(&root, std::span<const uint8_t>(w.begin.p, w.begin.len),
|
insert(&root, std::span<const uint8_t>(w.begin.p, w.begin.len),
|
||||||
|
Reference in New Issue
Block a user