Browse Source

meta: reduce symbol size of meta assoc traits ::find function

Michele Caini 2 years ago
parent
commit
54be0c2d9c
2 changed files with 5 additions and 5 deletions
  1. 3 3
      src/entt/meta/container.hpp
  2. 2 2
      src/entt/meta/meta.hpp

+ 3 - 3
src/entt/meta/container.hpp

@@ -139,13 +139,13 @@ struct basic_meta_associative_container_traits {
         return 0u;
         return 0u;
     }
     }
 
 
-    [[nodiscard]] static iterator find(const meta_ctx &ctx, any &container, meta_any &key) {
+    [[nodiscard]] static iterator find(const meta_ctx &ctx, void *container, const void *as_const, meta_any &key) {
         if(key.allow_cast<const typename Type::key_type &>()) {
         if(key.allow_cast<const typename Type::key_type &>()) {
-            if(auto *const cont = any_cast<Type>(&container); cont) {
+            if(auto *const cont = static_cast<Type *>(container); cont) {
                 return iterator{ctx, std::bool_constant<key_only>{}, cont->find(key.cast<const typename Type::key_type &>())};
                 return iterator{ctx, std::bool_constant<key_only>{}, cont->find(key.cast<const typename Type::key_type &>())};
             }
             }
 
 
-            return iterator{ctx, std::bool_constant<key_only>{}, any_cast<const Type &>(container).find(key.cast<const typename Type::key_type &>())};
+            return iterator{ctx, std::bool_constant<key_only>{}, static_cast<const Type *>(as_const)->find(key.cast<const typename Type::key_type &>())};
         }
         }
 
 
         return iterator{};
         return iterator{};

+ 2 - 2
src/entt/meta/meta.hpp

@@ -145,7 +145,7 @@ private:
     bool (*clear_fn)(any &){};
     bool (*clear_fn)(any &){};
     iterator (*iter_fn)(const meta_ctx &, any &, const bool){};
     iterator (*iter_fn)(const meta_ctx &, any &, const bool){};
     size_type (*insert_or_erase_fn)(any &, meta_any &, meta_any &){};
     size_type (*insert_or_erase_fn)(any &, meta_any &, meta_any &){};
-    iterator (*find_fn)(const meta_ctx &, any &, meta_any &){};
+    iterator (*find_fn)(const meta_ctx &, void *, const void *, meta_any &){};
     any storage{};
     any storage{};
 };
 };
 
 
@@ -2001,7 +2001,7 @@ inline meta_associative_container::size_type meta_associative_container::erase(m
  * @return An iterator to the element with the given key, if any.
  * @return An iterator to the element with the given key, if any.
  */
  */
 [[nodiscard]] inline meta_associative_container::iterator meta_associative_container::find(meta_any key) {
 [[nodiscard]] inline meta_associative_container::iterator meta_associative_container::find(meta_any key) {
-    return find_fn(*ctx, storage, key);
+    return find_fn(*ctx, storage.data(), std::as_const(storage).data(), key);
 }
 }
 
 
 /**
 /**