diff --git a/.clang-tidy b/.clang-tidy index b8d4665..f2dc035 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -70,6 +70,14 @@ CheckOptions: value: CamelCase - key: readability-identifier-naming.TemplateParameterCase value: CamelCase + - key: readability-identifier-length.MinimumParameterNameLength + value: 2 + - key: readability-identifier-length.MinimumVariableNameLength + value: 2 + - key: cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues + value: true + - key: readability-magic-numbers.IgnorePowersOf2IntegerValues + value: true # Workaround for https://github.com/llvm/llvm-project/issues/46097 - key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp value: expr-type diff --git a/include/slimlog/sink-inl.h b/include/slimlog/sink-inl.h index aac2202..96efdfc 100644 --- a/include/slimlog/sink-inl.h +++ b/include/slimlog/sink-inl.h @@ -27,8 +27,8 @@ #include #include #include -#include #include +#include namespace SlimLog { @@ -139,14 +139,16 @@ template auto SinkDriver::add_child(SinkDriver* child) -> void { const typename ThreadingPolicy::WriteLock lock(m_mutex); - m_children.insert(child); + m_children.push_back(child); } template auto SinkDriver::remove_child(SinkDriver* child) -> void { const typename ThreadingPolicy::WriteLock lock(m_mutex); - m_children.erase(child); + if (auto it = std::find(m_children.begin(), m_children.end(), child); it != m_children.end()) { + m_children.erase(it); + } } template @@ -192,16 +194,16 @@ auto SinkDriver::update_effective_sinks(SinkDriver* dri // Move to the next sibling or parent's sibling SinkDriver* prev = driver; while (parent && !next) { - if (auto prev_it = parent->m_children.find(prev); - std::distance(prev_it, parent->m_children.end()) > 1) { - next = *std::next(prev_it); + if (auto it = std::find(parent->m_children.begin(), parent->m_children.end(), prev); + std::distance(it, parent->m_children.end()) > 1) { + next = *std::next(it); } prev = parent; parent = parent->m_parent != this ? parent->m_parent : nullptr; } } else { // Nove to next level - next = *driver->m_children.begin(); + next = driver->m_children.front(); } return next; diff --git a/include/slimlog/sink.h b/include/slimlog/sink.h index e5ca07d..1f986ae 100644 --- a/include/slimlog/sink.h +++ b/include/slimlog/sink.h @@ -17,8 +17,8 @@ #include #include #include -#include #include +#include namespace SlimLog { @@ -359,7 +359,7 @@ class SinkDriver final { const Logger* m_logger; SinkDriver* m_parent; - std::unordered_set m_children; + std::vector m_children; std::unordered_map*, const Logger*> m_effective_sinks; std::unordered_map>, bool> m_sinks; mutable ThreadingPolicy::Mutex m_mutex;