Skip to content

Commit 2aebecb

Browse files
committed
meta: reduce branches a little
1 parent 499de3b commit 2aebecb

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎src/entt/meta/meta.hpp‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,15 @@ class meta_any final {
474474
if(storage.has_value<stl::remove_cvref_t<Type>>()) {
475475
return as_ref();
476476
} else if(*this) {
477+
const auto &from = fetch_node();
478+
477479
if constexpr(stl::is_arithmetic_v<stl::remove_cvref_t<Type>> || stl::is_enum_v<stl::remove_cvref_t<Type>>) {
478-
if(const auto &from = fetch_node(); from.conversion_helper) {
480+
if(from.conversion_helper) {
479481
return meta_any{*ctx, static_cast<Type>(from.conversion_helper(nullptr, storage.data()))};
480482
}
481483
}
482484

483-
if(const auto &from = fetch_node(); from.details != nullptr) {
485+
if(from.details != nullptr) {
484486
if(const auto *elem = internal::find_member(from.details->conv, entt::type_hash<stl::remove_cvref_t<Type>>::value()); elem != nullptr) {
485487
return elem->conv(*ctx, storage.data());
486488
}
@@ -1437,14 +1439,16 @@ bool meta_any::set(const id_type id, auto &&...args) {
14371439
if(storage.has_value(type.info())) {
14381440
return as_ref();
14391441
} else if(*this) {
1440-
if(const auto &from = fetch_node(); (from.conversion_helper != nullptr) && (type.is_arithmetic() || type.is_enum())) {
1442+
const auto &from = fetch_node();
1443+
1444+
if((from.conversion_helper != nullptr) && (type.is_arithmetic() || type.is_enum())) {
14411445
auto other = type.construct();
14421446
const auto value = from.conversion_helper(nullptr, storage.data());
14431447
other.fetch_node().conversion_helper(other.storage.data(), &value);
14441448
return other;
14451449
}
14461450

1447-
if(const auto &from = fetch_node(); from.details) {
1451+
if(from.details) {
14481452
if(const auto *elem = internal::find_member(from.details->conv, type.info().hash()); elem != nullptr) {
14491453
return elem->conv(*ctx, storage.data());
14501454
}

0 commit comments

Comments
 (0)