From bcc9195cdbbf27367b4fa0c33b4ee84b15e1566a Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 22 Jan 2024 13:15:09 -0800 Subject: [PATCH] Remove anon namespaces (not needed with visibility=hidden) --- ConflictSet.cpp | 63 +++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 0db067a..58b7637 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -93,7 +93,6 @@ Arena::Arena(int initialSize) : impl(nullptr) { } } -namespace { void onDestroy(Arena::ArenaImpl *impl) { while (impl) { auto *prev = impl->prev; @@ -101,7 +100,6 @@ void onDestroy(Arena::ArenaImpl *impl) { impl = prev; } } -} // namespace Arena::Arena(Arena &&other) noexcept : impl(std::exchange(other.impl, nullptr)) {} @@ -429,6 +427,36 @@ uint32_t Arbitrary::bounded(uint32_t s) { // ==================== END ARBITRARY IMPL ==================== +// ==================== BEGIN UTILITIES IMPL ==================== + +// Call Stepwise::step for each element of remaining until it returns true. +// Applies a permutation to `remaining` as a side effect. +template void runInterleaved(std::span remaining) { + while (remaining.size() > 0) { + for (int i = 0; i < int(remaining.size());) { + bool done = remaining[i].step(); + if (done) { + if (i != int(remaining.size()) - 1) { + using std::swap; + swap(remaining[i], remaining.back()); + } + remaining = remaining.subspan(0, remaining.size() - 1); + } else { + ++i; + } + } + } +}; + +template void runSequential(std::span remaining) { + for (auto &r : remaining) { + while (!r.step()) { + } + } +} + +// ==================== END UTILITIES IMPL ==================== + #define SHOW_PRIORITY 0 #define DEBUG 0 @@ -440,7 +468,6 @@ static auto operator<=>(const Key &lhs, const Key &rhs) { return c != 0 ? c <=> 0 : lhs.len <=> rhs.len; } -namespace { // A node in the tree representing write conflict history. This tree maintains // several invariants: @@ -519,32 +546,6 @@ struct Iterator { int cmp; }; -// Call Stepwise::step for each element of remaining until it returns true. -// Applies a permutation to `remaining` as a side effect. -template void runInterleaved(std::span remaining) { - while (remaining.size() > 0) { - for (int i = 0; i < int(remaining.size());) { - bool done = remaining[i].step(); - if (done) { - if (i != int(remaining.size()) - 1) { - using std::swap; - swap(remaining[i], remaining.back()); - } - remaining = remaining.subspan(0, remaining.size() - 1); - } else { - ++i; - } - } - } -}; - -template void runSequential(std::span remaining) { - for (auto &r : remaining) { - while (!r.step()) { - } - } -} - struct StepwiseLastLeq { Node *current; Node *result; @@ -878,8 +879,6 @@ bool checkCorrectness(Node *node, ReferenceImpl &refImpl) { return success; } -} // namespace - struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl { Random rand; Node *root; @@ -1134,7 +1133,6 @@ namespace std { void __throw_length_error(const char *) { __builtin_unreachable(); } } // namespace std -namespace { struct ReferenceImpl { explicit ReferenceImpl(int64_t oldestVersion) : oldestVersion(oldestVersion) { writeVersionMap[""] = oldestVersion; @@ -1201,7 +1199,6 @@ struct ReferenceImpl { int64_t oldestVersion; std::map writeVersionMap; }; -} // namespace #ifdef ENABLE_TESTS int main(void) {