meta: reduce symbol size of meta assoc traits ::insert_or_erase function
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -144,7 +144,7 @@ private:
|
||||
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{};
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user