Browse Source

meta: further reduce symbol size of meta seq traits ::size function

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

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

@@ -49,9 +49,9 @@ struct basic_meta_sequence_container_traits {
         return any_cast<const Type &>(container).size();
     }
 
-    [[nodiscard]] static bool resize([[maybe_unused]] any &container, [[maybe_unused]] size_type sz) {
+    [[nodiscard]] static bool resize([[maybe_unused]] void *container, [[maybe_unused]] size_type sz) {
         if constexpr(is_dynamic_sequence_container<Type>::value) {
-            any_cast<Type &>(container).resize(sz);
+            static_cast<Type *>(container)->resize(sz);
             return true;
         } else {
             return false;

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

@@ -74,7 +74,7 @@ private:
     const meta_ctx *ctx{};
     internal::meta_type_node (*value_type_node)(const internal::meta_context &){};
     size_type (*size_fn)(const any &) noexcept {};
-    bool (*resize_fn)(any &, size_type){};
+    bool (*resize_fn)(void *, size_type){};
     iterator (*iter_fn)(const meta_ctx &, any &, const bool){};
     iterator (*insert_or_erase_fn)(const meta_ctx &, any &, const any &, meta_any &){};
     any storage{};
@@ -1840,7 +1840,8 @@ private:
  * @return True in case of success, false otherwise.
  */
 inline bool meta_sequence_container::resize(const size_type sz) {
-    return storage.data() && resize_fn(storage, sz);
+    void *elem = storage.data();
+    return elem && resize_fn(elem, sz);
 }
 
 /**
@@ -1848,7 +1849,8 @@ inline bool meta_sequence_container::resize(const size_type sz) {
  * @return True in case of success, false otherwise.
  */
 inline bool meta_sequence_container::clear() {
-    return storage.data() && resize_fn(storage, 0u);
+    void *elem = storage.data();
+    return elem && resize_fn(elem, 0u);
 }
 
 /**