Skip to content

Commit

Permalink
fix(core): do not use else after return
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 610bd00 commit a30aab1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
20 changes: 8 additions & 12 deletions core/include/cubos/core/reflection/external/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map<K, V>))
return new typename Map::iterator(reinterpret_cast<Map*>(instance)->begin());
}

{
return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());
}
return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());

} /*begin*/,
[](uintptr_t instance, const void* key, bool writeable) -> void* {
if (writeable)
Expand All @@ -38,14 +37,13 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map<K, V>))
return new typename Map::iterator(it);
}

{
auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
if (it == reinterpret_cast<const Map*>(instance)->end())
{
return nullptr;
}
return new typename Map::const_iterator(it);
}

} /*find*/,
[](uintptr_t instance, void* iterator, bool writeable) -> bool {
if (writeable)
Expand Down Expand Up @@ -75,19 +73,17 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map<K, V>))
return &(*static_cast<const typename Map::iterator*>(iterator))->first;
}

{
return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;
}
return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;

} /*key*/,
[](const void* iterator, bool writeable) -> uintptr_t {
if (writeable)
{
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::iterator*>(iterator))->second);
}

{
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);
}
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);

} /*value*/);

// We supply the insert functions depending on the constructibility of the value type.
Expand Down
25 changes: 10 additions & 15 deletions core/include/cubos/core/reflection/external/unordered_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map<K,
return new typename Map::iterator(reinterpret_cast<Map*>(instance)->begin());
}

{
return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());
}
return new typename Map::const_iterator(reinterpret_cast<const Map*>(instance)->cbegin());

} /*begin*/,
[](uintptr_t instance, const void* key, bool writeable) -> void* {
if (writeable)
Expand All @@ -38,14 +37,13 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map<K,
return new typename Map::iterator(it);
}

{
auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
auto it = reinterpret_cast<const Map*>(instance)->find(*reinterpret_cast<const K*>(key));
if (it == reinterpret_cast<const Map*>(instance)->end())
{
return nullptr;
}
return new typename Map::const_iterator(it);
}

} /*find*/,
[](uintptr_t instance, void* iterator, bool writeable) {
if (writeable)
Expand All @@ -54,10 +52,9 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map<K,
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 All @@ -75,19 +72,17 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map<K,
return &(*static_cast<const typename Map::iterator*>(iterator))->first;
}

{
return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;
}
return &(*static_cast<const typename Map::const_iterator*>(iterator))->first;

} /*key*/,
[](const void* iterator, bool writeable) -> uintptr_t {
if (writeable)
{
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::iterator*>(iterator))->second);
}

{
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);
}
return reinterpret_cast<uintptr_t>(&(*static_cast<const typename Map::const_iterator*>(iterator))->second);

} /*value*/);

// We supply the insert functions depending on the constructibility of the value type.
Expand Down

0 comments on commit a30aab1

Please sign in to comment.