From 7283c7067bf9dd8ea43e94029e5b315999425026 Mon Sep 17 00:00:00 2001 From: Ricardo Antunes Date: Tue, 26 Sep 2023 15:26:29 +0100 Subject: [PATCH] fix(core): follow clang-tidy suggestions Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../cubos/core/reflection/external/map.hpp | 5 ++-- .../core/reflection/traits/dictionary.hpp | 4 +-- .../core/reflection/traits/dictionary.cpp | 26 +++++++++---------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/core/include/cubos/core/reflection/external/map.hpp b/core/include/cubos/core/reflection/external/map.hpp index d66728c036..1016c50192 100644 --- a/core/include/cubos/core/reflection/external/map.hpp +++ b/core/include/cubos/core/reflection/external/map.hpp @@ -52,10 +52,9 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map)) return *static_cast(iterator) != reinterpret_cast(instance)->end(); } - { - ++*static_cast(iterator); + ++*static_cast(iterator); return *static_cast(iterator) != reinterpret_cast(instance)->cend(); - } + } /*advance*/, [](void* iterator, bool writeable) { if (writeable) diff --git a/core/include/cubos/core/reflection/traits/dictionary.hpp b/core/include/cubos/core/reflection/traits/dictionary.hpp index 3a793dd921..cf6d3c9439 100644 --- a/core/include/cubos/core/reflection/traits/dictionary.hpp +++ b/core/include/cubos/core/reflection/traits/dictionary.hpp @@ -224,7 +224,7 @@ namespace cubos::core::reflection /// @brief Move constructs. /// @param other Other iterator. - Iterator(Iterator&& other); + Iterator(Iterator&& other) noexcept ; /// @brief Gets a pointer to the current key. /// @note Aborts if @ref isNull() returns true. @@ -270,7 +270,7 @@ namespace cubos::core::reflection /// @brief Move constructs. /// @param other Other iterator. - ConstIterator(ConstIterator&& other); + ConstIterator(ConstIterator&& other) noexcept ; /// @brief Gets a pointer to the current key. /// @note Aborts if @ref isNull() returns true. diff --git a/core/src/cubos/core/reflection/traits/dictionary.cpp b/core/src/cubos/core/reflection/traits/dictionary.cpp index 21bc4698ee..cc2886d838 100644 --- a/core/src/cubos/core/reflection/traits/dictionary.cpp +++ b/core/src/cubos/core/reflection/traits/dictionary.cpp @@ -83,7 +83,7 @@ DictionaryTrait::ConstIterator DictionaryTrait::find(const void* instance, const bool DictionaryTrait::insertDefault(void* instance, const void* key) const { - if (mInsertDefault) + if (mInsertDefault != nullptr) { mInsertDefault(instance, key); return true; @@ -94,7 +94,7 @@ bool DictionaryTrait::insertDefault(void* instance, const void* key) const bool DictionaryTrait::insertCopy(void* instance, const void* key, const void* value) const { - if (mInsertCopy) + if (mInsertCopy != nullptr) { mInsertCopy(instance, key, value); return true; @@ -105,7 +105,7 @@ bool DictionaryTrait::insertCopy(void* instance, const void* key, const void* va bool DictionaryTrait::insertMove(void* instance, const void* key, void* value) const { - if (mInsertMove) + if (mInsertMove != nullptr) { mInsertMove(instance, key, value); return true; @@ -118,7 +118,7 @@ bool DictionaryTrait::erase(void* instance, Iterator& iterator) const { CUBOS_ASSERT(!iterator.isNull(), "Cannot erase null iterator"); - if (mErase) + if (mErase != nullptr) { mErase(instance, iterator.mInner, true); mStop(iterator.mInner, true); @@ -133,7 +133,7 @@ bool DictionaryTrait::erase(void* instance, ConstIterator& iterator) const { CUBOS_ASSERT(!iterator.isNull(), "Cannot erase null iterator"); - if (mErase) + if (mErase != nullptr) { mErase(instance, iterator.mInner, false); mStop(iterator.mInner, false); @@ -146,27 +146,27 @@ bool DictionaryTrait::erase(void* instance, ConstIterator& iterator) const bool DictionaryTrait::hasInsertDefault() const { - return mInsertDefault; + return mInsertDefault != nullptr; } bool DictionaryTrait::hasInsertCopy() const { - return mInsertCopy; + return mInsertCopy != nullptr; } bool DictionaryTrait::hasInsertMove() const { - return mInsertMove; + return mInsertMove != nullptr; } bool DictionaryTrait::hasErase() const { - return mErase; + return mErase != nullptr; } DictionaryTrait::Iterator::~Iterator() { - if (mInner) + if (mInner != nullptr) { mTrait.mStop(mInner, true); } @@ -191,7 +191,7 @@ DictionaryTrait::Iterator::Iterator(const Iterator& other) } DictionaryTrait::Iterator::Iterator(Iterator&& other) - : mInner(other.mInner) + noexcept : mInner(other.mInner) , mInstance(other.mInstance) , mTrait(other.mTrait) { @@ -230,7 +230,7 @@ bool DictionaryTrait::Iterator::isNull() const DictionaryTrait::ConstIterator::~ConstIterator() { - if (mInner) + if (mInner != nullptr) { mTrait.mStop(mInner, false); } @@ -255,7 +255,7 @@ DictionaryTrait::ConstIterator::ConstIterator(const ConstIterator& other) } DictionaryTrait::ConstIterator::ConstIterator(ConstIterator&& other) - : mInner(other.mInner) + noexcept : mInner(other.mInner) , mInstance(other.mInstance) , mTrait(other.mTrait) {