From a30aab1412829eb70dc24e604f4f12a126ea62cc Mon Sep 17 00:00:00 2001 From: Ricardo Antunes Date: Tue, 26 Sep 2023 15:23:56 +0100 Subject: [PATCH] fix(core): do not use else after return Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../cubos/core/reflection/external/map.hpp | 20 ++++++--------- .../reflection/external/unordered_map.hpp | 25 ++++++++----------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/core/include/cubos/core/reflection/external/map.hpp b/core/include/cubos/core/reflection/external/map.hpp index 5f95ede7dd..d66728c036 100644 --- a/core/include/cubos/core/reflection/external/map.hpp +++ b/core/include/cubos/core/reflection/external/map.hpp @@ -23,9 +23,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map)) return new typename Map::iterator(reinterpret_cast(instance)->begin()); } - { - return new typename Map::const_iterator(reinterpret_cast(instance)->cbegin()); - } + return new typename Map::const_iterator(reinterpret_cast(instance)->cbegin()); + } /*begin*/, [](uintptr_t instance, const void* key, bool writeable) -> void* { if (writeable) @@ -38,14 +37,13 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map)) return new typename Map::iterator(it); } - { - auto it = reinterpret_cast(instance)->find(*reinterpret_cast(key)); + auto it = reinterpret_cast(instance)->find(*reinterpret_cast(key)); if (it == reinterpret_cast(instance)->end()) { return nullptr; } return new typename Map::const_iterator(it); - } + } /*find*/, [](uintptr_t instance, void* iterator, bool writeable) -> bool { if (writeable) @@ -75,9 +73,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map)) return &(*static_cast(iterator))->first; } - { - return &(*static_cast(iterator))->first; - } + return &(*static_cast(iterator))->first; + } /*key*/, [](const void* iterator, bool writeable) -> uintptr_t { if (writeable) @@ -85,9 +82,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::map)) return reinterpret_cast(&(*static_cast(iterator))->second); } - { - return reinterpret_cast(&(*static_cast(iterator))->second); - } + return reinterpret_cast(&(*static_cast(iterator))->second); + } /*value*/); // We supply the insert functions depending on the constructibility of the value type. diff --git a/core/include/cubos/core/reflection/external/unordered_map.hpp b/core/include/cubos/core/reflection/external/unordered_map.hpp index bfabecbe5b..44bc293623 100644 --- a/core/include/cubos/core/reflection/external/unordered_map.hpp +++ b/core/include/cubos/core/reflection/external/unordered_map.hpp @@ -23,9 +23,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map(instance)->begin()); } - { - return new typename Map::const_iterator(reinterpret_cast(instance)->cbegin()); - } + return new typename Map::const_iterator(reinterpret_cast(instance)->cbegin()); + } /*begin*/, [](uintptr_t instance, const void* key, bool writeable) -> void* { if (writeable) @@ -38,14 +37,13 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map(instance)->find(*reinterpret_cast(key)); + auto it = reinterpret_cast(instance)->find(*reinterpret_cast(key)); if (it == reinterpret_cast(instance)->end()) { return nullptr; } return new typename Map::const_iterator(it); - } + } /*find*/, [](uintptr_t instance, void* iterator, bool writeable) { if (writeable) @@ -54,10 +52,9 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map(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) @@ -75,9 +72,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map(iterator))->first; } - { - return &(*static_cast(iterator))->first; - } + return &(*static_cast(iterator))->first; + } /*key*/, [](const void* iterator, bool writeable) -> uintptr_t { if (writeable) @@ -85,9 +81,8 @@ CUBOS_REFLECT_EXTERNAL_TEMPLATE((typename K, typename V), (std::unordered_map(&(*static_cast(iterator))->second); } - { - return reinterpret_cast(&(*static_cast(iterator))->second); - } + return reinterpret_cast(&(*static_cast(iterator))->second); + } /*value*/); // We supply the insert functions depending on the constructibility of the value type.