Browse Source

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

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

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

@@ -58,13 +58,13 @@ struct basic_meta_sequence_container_traits {
         }
     }
 
-    [[nodiscard]] static iterator iter(const meta_ctx &ctx, any &container, const bool as_end) {
-        if(auto *const cont = any_cast<Type>(&container); cont) {
+    [[nodiscard]] static iterator iter(const meta_ctx &ctx, void *container, const void *as_const, const bool as_end) {
+        if(auto *const cont = static_cast<Type *>(container); cont) {
             return iterator{ctx, as_end ? cont->end() : cont->begin()};
         }
 
-        const Type &as_const = any_cast<const Type &>(container);
-        return iterator{ctx, as_end ? as_const.end() : as_const.begin()};
+        auto *const cont = static_cast<const Type *>(as_const);
+        return iterator{ctx, as_end ? cont->end() : cont->begin()};
     }
 
     [[nodiscard]] static iterator insert_or_erase([[maybe_unused]] const meta_ctx &ctx, [[maybe_unused]] any &container, [[maybe_unused]] const any &handle, [[maybe_unused]] meta_any &value) {

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

@@ -75,7 +75,7 @@ private:
     internal::meta_type_node (*value_type_node)(const internal::meta_context &){};
     size_type (*size_fn)(const void *) noexcept {};
     bool (*resize_fn)(void *, size_type){};
-    iterator (*iter_fn)(const meta_ctx &, any &, const bool){};
+    iterator (*iter_fn)(const meta_ctx &, void *, const void *, const bool){};
     iterator (*insert_or_erase_fn)(const meta_ctx &, any &, const any &, meta_any &){};
     any storage{};
 };
@@ -1867,7 +1867,7 @@ inline bool meta_sequence_container::clear() {
  * @return An iterator to the first element of the container.
  */
 [[nodiscard]] inline meta_sequence_container::iterator meta_sequence_container::begin() {
-    return iter_fn(*ctx, storage, false);
+    return iter_fn(*ctx, storage.data(), std::as_const(storage).data(), false);
 }
 
 /**
@@ -1875,7 +1875,7 @@ inline bool meta_sequence_container::clear() {
  * @return An iterator that is past the last element of the container.
  */
 [[nodiscard]] inline meta_sequence_container::iterator meta_sequence_container::end() {
-    return iter_fn(*ctx, storage, true);
+    return iter_fn(*ctx, storage.data(), std::as_const(storage).data(), true);
 }
 
 /**