From 6113530143893f02f1ec1836328f884c4e43e823 Mon Sep 17 00:00:00 2001 From: semenov_gv Date: Fri, 26 Nov 2021 13:22:38 +0300 Subject: [PATCH] Code refactor rttr core and tests --- src/rttr/detail/library/library_win.cpp | 2 -- src/rttr/detail/metadata/metadata.h | 2 +- src/rttr/detail/registration/registration_executer.cpp | 4 +--- src/rttr/detail/type/type_register.cpp | 4 ++-- .../variant_sequential_view_private.h | 5 +---- src/rttr/library.cpp | 2 +- src/rttr/registration.h | 2 +- src/rttr/variant_associative_view.cpp | 8 ++------ src/rttr/variant_sequential_view.cpp | 8 ++------ src/unit_tests/variant/variant_conv_to_string.cpp | 4 ++-- src/unit_tests/visitor/visitor_test_class.cpp | 2 +- 11 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/rttr/detail/library/library_win.cpp b/src/rttr/detail/library/library_win.cpp index 5baded65..397ac761 100644 --- a/src/rttr/detail/library/library_win.cpp +++ b/src/rttr/detail/library/library_win.cpp @@ -201,8 +201,6 @@ bool library_private::load_native() { std::wstring wfile_name = convert_utf8_to_utf16(m_file_name); - std::vector paths_to_try; - std::vector prefix_list = {L"lib"}; std::vector suffix_list = {L".dll"}; diff --git a/src/rttr/detail/metadata/metadata.h b/src/rttr/detail/metadata/metadata.h index 3cf67ab6..dacbbcff 100644 --- a/src/rttr/detail/metadata/metadata.h +++ b/src/rttr/detail/metadata/metadata.h @@ -43,7 +43,7 @@ namespace detail class RTTR_API metadata { public: - metadata() { } + metadata() = default; metadata(variant key, variant value) : m_key(std::move(key)), m_value(std::move(value)) { } metadata(const metadata& other) : m_key(other.m_key), m_value(other.m_value) {} metadata(metadata&& other) : m_key(std::move(other.m_key)), m_value(std::move(other.m_value)) {} diff --git a/src/rttr/detail/registration/registration_executer.cpp b/src/rttr/detail/registration/registration_executer.cpp index 1f8418b1..fde70985 100644 --- a/src/rttr/detail/registration/registration_executer.cpp +++ b/src/rttr/detail/registration/registration_executer.cpp @@ -36,9 +36,7 @@ namespace detail ///////////////////////////////////////////////////////////////////////////////////////// -registration_executer::registration_executer() -{ -} +registration_executer::registration_executer() = default; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/rttr/detail/type/type_register.cpp b/src/rttr/detail/type/type_register.cpp index 25181117..4b486ee6 100644 --- a/src/rttr/detail/type/type_register.cpp +++ b/src/rttr/detail/type/type_register.cpp @@ -644,8 +644,8 @@ std::string type_register_private::derive_template_instance_name(type_data* info if (has_custom_name) return info->name; - const auto start_pos = info->name.find("<"); - const auto end_pos = info->name.rfind(">"); + const auto start_pos = info->name.find('<'); + const auto end_pos = info->name.rfind('>'); if (start_pos == std::string::npos || end_pos == std::string::npos) return info->name; diff --git a/src/rttr/detail/variant_sequential_view/variant_sequential_view_private.h b/src/rttr/detail/variant_sequential_view/variant_sequential_view_private.h index a13aeffc..44a7ef9c 100644 --- a/src/rttr/detail/variant_sequential_view/variant_sequential_view_private.h +++ b/src/rttr/detail/variant_sequential_view/variant_sequential_view_private.h @@ -97,10 +97,7 @@ class RTTR_LOCAL variant_sequential_view_private RTTR_INLINE variant_sequential_view_private(const variant_sequential_view_private& other) = default; - RTTR_INLINE ~variant_sequential_view_private() - { - - } + RTTR_INLINE ~variant_sequential_view_private() = default; RTTR_INLINE type get_type() const RTTR_NOEXCEPT { diff --git a/src/rttr/library.cpp b/src/rttr/library.cpp index 55b70ffa..4e84e924 100644 --- a/src/rttr/library.cpp +++ b/src/rttr/library.cpp @@ -79,7 +79,7 @@ class library_manager } private: - library_manager() {} + library_manager() = default; static library_manager& get_instance() { diff --git a/src/rttr/registration.h b/src/rttr/registration.h index 636973cd..fc06a405 100644 --- a/src/rttr/registration.h +++ b/src/rttr/registration.h @@ -434,7 +434,7 @@ class RTTR_API registration static const detail::private_access private_access; private: - registration() {} + registration() = default; registration(const std::shared_ptr& reg_exec) : m_reg_exec(reg_exec) { } registration(const registration& other); registration& operator=(const registration& other); diff --git a/src/rttr/variant_associative_view.cpp b/src/rttr/variant_associative_view.cpp index ee2119cc..785f3685 100644 --- a/src/rttr/variant_associative_view.cpp +++ b/src/rttr/variant_associative_view.cpp @@ -38,9 +38,7 @@ namespace rttr ///////////////////////////////////////////////////////////////////////////////// -variant_associative_view::variant_associative_view() -{ -} + variant_associative_view::variant_associative_view() = default; ///////////////////////////////////////////////////////////////////////////////// @@ -52,9 +50,7 @@ variant_associative_view::variant_associative_view(const variant_associative_vie ///////////////////////////////////////////////////////////////////////////////// -variant_associative_view::~variant_associative_view() RTTR_NOEXCEPT -{ -} +variant_associative_view::~variant_associative_view() RTTR_NOEXCEPT = default; ///////////////////////////////////////////////////////////////////////////////// diff --git a/src/rttr/variant_sequential_view.cpp b/src/rttr/variant_sequential_view.cpp index 381e3e8f..de23bcf9 100644 --- a/src/rttr/variant_sequential_view.cpp +++ b/src/rttr/variant_sequential_view.cpp @@ -38,9 +38,7 @@ namespace rttr ///////////////////////////////////////////////////////////////////////////////// -variant_sequential_view::variant_sequential_view() -{ -} +variant_sequential_view::variant_sequential_view() = default; ///////////////////////////////////////////////////////////////////////////////// @@ -52,9 +50,7 @@ variant_sequential_view::variant_sequential_view(const variant_sequential_view& ///////////////////////////////////////////////////////////////////////////////// -variant_sequential_view::~variant_sequential_view() RTTR_NOEXCEPT -{ -} +variant_sequential_view::~variant_sequential_view() RTTR_NOEXCEPT = default; ///////////////////////////////////////////////////////////////////////////////// diff --git a/src/unit_tests/variant/variant_conv_to_string.cpp b/src/unit_tests/variant/variant_conv_to_string.cpp index 99177bcf..d1c47163 100644 --- a/src/unit_tests/variant/variant_conv_to_string.cpp +++ b/src/unit_tests/variant/variant_conv_to_string.cpp @@ -51,7 +51,7 @@ TEST_CASE("variant::to_string() - from empty", "[variant]") { variant var; bool ok = false; - CHECK(var.to_string(&ok) == ""); + CHECK(var.to_string(&ok).empty()); CHECK(ok == false); } @@ -400,7 +400,7 @@ TEST_CASE("variant::to_string() - from enum", "[variant]") { variant var = unregisterd_enum::VALUE_1; bool ok = false; - CHECK(var.to_string(&ok) == ""); + CHECK(var.to_string(&ok).empty()); CHECK(ok == false); CHECK(var.convert(type::get()) == false); } diff --git a/src/unit_tests/visitor/visitor_test_class.cpp b/src/unit_tests/visitor/visitor_test_class.cpp index 428e7205..7b8da17f 100644 --- a/src/unit_tests/visitor/visitor_test_class.cpp +++ b/src/unit_tests/visitor/visitor_test_class.cpp @@ -37,7 +37,7 @@ static bool get_prop_as_function() { return true; } static std::string g_text; -static void set_global_value(std::string text) { g_text = text; } +static void set_global_value(const std::string& text) { g_text = std::move(text); } static std::string get_global_value() { return g_text; } using namespace rttr;