Explorar o código

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

Michele Caini %!s(int64=2) %!d(string=hai) anos
pai
achega
54be0c2d9c
Modificáronse 2 ficheiros con 5 adicións e 5 borrados
  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;
     }
 
-    [[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(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>{}, 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{};

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

@@ -145,7 +145,7 @@ private:
     bool (*clear_fn)(any &){};
     iterator (*iter_fn)(const meta_ctx &, any &, const bool){};
     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{};
 };
 
@@ -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.
  */
 [[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);
 }
 
 /**