Skip to content

Commit

Permalink
meta: reduce symbol size of meta assoc traits ::insert_or_erase function
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Jul 4, 2023
1 parent 444d44a commit d00a4c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/entt/meta/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ struct basic_meta_associative_container_traits {
return iterator{ctx, std::bool_constant<key_only>{}, as_end ? cont->end() : cont->begin()};
}

[[nodiscard]] static size_type insert_or_erase(any &container, meta_any &key, meta_any &value) {
if(auto *const cont = any_cast<Type>(&container); cont && key.allow_cast<const typename Type::key_type &>()) {
[[nodiscard]] static size_type insert_or_erase(void *container, meta_any &key, meta_any &value) {
if(auto *const cont = static_cast<Type *>(container); key.allow_cast<const typename Type::key_type &>()) {
if(value) {
if constexpr(key_only) {
return cont->insert(key.cast<const typename Type::key_type &>()).second;
Expand Down
6 changes: 3 additions & 3 deletions src/entt/meta/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class meta_associative_container {
size_type (*size_fn)(const void *) noexcept {};
bool (*clear_fn)(void *){};
iterator (*iter_fn)(const meta_ctx &, void *, const void *, const bool){};
size_type (*insert_or_erase_fn)(any &, meta_any &, meta_any &){};
size_type (*insert_or_erase_fn)(void *, meta_any &, meta_any &){};
iterator (*find_fn)(const meta_ctx &, void *, const void *, meta_any &){};
any storage{};
};
Expand Down Expand Up @@ -1973,7 +1973,7 @@ inline bool meta_associative_container::clear() {
*/
inline bool meta_associative_container::insert(meta_any key) {
meta_any value{*ctx, std::in_place_type<void>};
return (insert_or_erase_fn(storage, key, value) != 0u);
return (storage.policy() != any_policy::cref) && (insert_or_erase_fn(storage.data(), key, value) != 0u);
}

/**
Expand All @@ -1983,7 +1983,7 @@ inline bool meta_associative_container::insert(meta_any key) {
* @return A bool denoting whether the insertion took place.
*/
inline bool meta_associative_container::insert(meta_any key, meta_any value) {
return (insert_or_erase_fn(storage, key, value) != 0u);
return (storage.policy() != any_policy::cref) && (insert_or_erase_fn(storage.data(), key, value) != 0u);
}

/**
Expand Down

0 comments on commit d00a4c4

Please sign in to comment.