Browse Source

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

Michele Caini 2 years ago
parent
commit
7efbc3f72d
2 changed files with 6 additions and 8 deletions
  1. 4 6
      src/entt/meta/container.hpp
  2. 2 2
      src/entt/meta/meta.hpp

+ 4 - 6
src/entt/meta/container.hpp

@@ -51,13 +51,11 @@ struct basic_meta_sequence_container_traits {
 
 
     [[nodiscard]] static bool resize([[maybe_unused]] any &container, [[maybe_unused]] size_type sz) {
     [[nodiscard]] static bool resize([[maybe_unused]] any &container, [[maybe_unused]] size_type sz) {
         if constexpr(is_dynamic_sequence_container<Type>::value) {
         if constexpr(is_dynamic_sequence_container<Type>::value) {
-            if(auto *const cont = any_cast<Type>(&container); cont) {
-                cont->resize(sz);
-                return true;
-            }
+            any_cast<Type &>(container).resize(sz);
+            return true;
+        } else {
+            return false;
         }
         }
-
-        return false;
     }
     }
 
 
     [[nodiscard]] static iterator iter(const meta_ctx &ctx, any &container, const bool as_end) {
     [[nodiscard]] static iterator iter(const meta_ctx &ctx, any &container, const bool as_end) {

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

@@ -1840,7 +1840,7 @@ private:
  * @return True in case of success, false otherwise.
  * @return True in case of success, false otherwise.
  */
  */
 inline bool meta_sequence_container::resize(const size_type sz) {
 inline bool meta_sequence_container::resize(const size_type sz) {
-    return resize_fn(storage, sz);
+    return storage.data() && resize_fn(storage, sz);
 }
 }
 
 
 /**
 /**
@@ -1848,7 +1848,7 @@ inline bool meta_sequence_container::resize(const size_type sz) {
  * @return True in case of success, false otherwise.
  * @return True in case of success, false otherwise.
  */
  */
 inline bool meta_sequence_container::clear() {
 inline bool meta_sequence_container::clear() {
-    return resize_fn(storage, 0u);
+    return storage.data() && resize_fn(storage, 0u);
 }
 }
 
 
 /**
 /**