diff --git a/src/rttr/detail/type/type_register.cpp b/src/rttr/detail/type/type_register.cpp index 5f486352..3ae5c421 100644 --- a/src/rttr/detail/type/type_register.cpp +++ b/src/rttr/detail/type/type_register.cpp @@ -1122,9 +1122,13 @@ flat_map& type_register_private::get_orig_name_to_id() ///////////////////////////////////////////////////////////////////////////////////// -flat_map& type_register_private::get_custom_name_to_id() +type type_register_private::get_type_by_custom_name(string_view name) { - return m_custom_name_to_id; + std::lock_guard lock(m_mutex); + auto ret = m_custom_name_to_id.find(name); + if (ret != m_custom_name_to_id.end()) + return (*ret); + return detail::get_invalid_type(); } ///////////////////////////////////////////////////////////////////////////////////// diff --git a/src/rttr/detail/type/type_register_p.h b/src/rttr/detail/type/type_register_p.h index 93188251..37eac0bc 100644 --- a/src/rttr/detail/type/type_register_p.h +++ b/src/rttr/detail/type/type_register_p.h @@ -103,7 +103,7 @@ class RTTR_LOCAL type_register_private std::vector& get_type_data_storage(); std::vector& get_type_storage(); flat_map& get_orig_name_to_id(); - flat_map& get_custom_name_to_id(); + type get_type_by_custom_name(string_view name); ///////////////////////////////////////////////////////////////////////////////////// diff --git a/src/rttr/type.cpp b/src/rttr/type.cpp index e8ac326e..e7dfdddb 100644 --- a/src/rttr/type.cpp +++ b/src/rttr/type.cpp @@ -486,12 +486,7 @@ variant type::invoke(string_view name, std::vector args) type type::get_by_name(string_view name) RTTR_NOEXCEPT { - auto& custom_name_to_id = detail::type_register_private::get_instance().get_custom_name_to_id(); - auto ret = custom_name_to_id.find(name); - if (ret != custom_name_to_id.end()) - return (*ret); - - return detail::get_invalid_type(); + return detail::type_register_private::get_instance().get_type_by_custom_name(name); } /////////////////////////////////////////////////////////////////////////////////////////