Skip to content

Commit

Permalink
fix(core): follow clang-tidy suggestions
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
RiscadoA and github-actions[bot] authored Sep 26, 2023
1 parent a30aab1 commit 7283c70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
5 changes: 2 additions & 3 deletions core/include/cubos/core/reflection/external/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map<K, V>))
return *static_cast<typename Map::iterator*>(iterator) != reinterpret_cast<Map*>(instance)->end();
}

{
++*static_cast<typename Map::const_iterator*>(iterator);
++*static_cast<typename Map::const_iterator*>(iterator);
return *static_cast<typename Map::const_iterator*>(iterator) != reinterpret_cast<const Map*>(instance)->cend();
}

} /*advance*/,
[](void* iterator, bool writeable) {
if (writeable)
Expand Down
4 changes: 2 additions & 2 deletions core/include/cubos/core/reflection/traits/dictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
26 changes: 13 additions & 13 deletions core/src/cubos/core/reflection/traits/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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)
{
Expand Down Expand Up @@ -230,7 +230,7 @@ bool DictionaryTrait::Iterator::isNull() const

DictionaryTrait::ConstIterator::~ConstIterator()
{
if (mInner)
if (mInner != nullptr)
{
mTrait.mStop(mInner, false);
}
Expand All @@ -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)
{
Expand Down

0 comments on commit 7283c70

Please sign in to comment.