Przeglądaj źródła

meta: reduce instantiations due to meta_prop

Michele Caini 5 lat temu
rodzic
commit
da14641ccb
3 zmienionych plików z 10 dodań i 10 usunięć
  1. 2 2
      src/entt/meta/factory.hpp
  2. 6 6
      src/entt/meta/meta.hpp
  3. 2 2
      src/entt/meta/node.hpp

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

@@ -110,8 +110,8 @@ private:
 
         static internal::meta_prop_node node{
             nullptr,
-            property,
-            property + 1u
+            property[0u],
+            property[1u]
         };
 
         entt::meta_any instance{std::forward<Key>(key)};

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

@@ -668,7 +668,7 @@ struct meta_prop {
      * @return A meta any containing the key stored with the property.
      */
     [[nodiscard]] meta_any key() const {
-        return node->id->as_ref();
+        return node->id.as_ref();
     }
 
     /**
@@ -676,7 +676,7 @@ struct meta_prop {
      * @return A meta any containing the value stored with the property.
      */
     [[nodiscard]] meta_any value() const {
-        return *node->value;
+        return node->value;
     }
 
     /**
@@ -768,7 +768,7 @@ struct meta_ctor {
      * @return The property associated with the given key, if any.
      */
     [[nodiscard]] meta_prop prop(meta_any key) const {
-        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return *curr->id == key; }, node);
+        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return curr->id == key; }, node);
     }
 
     /**
@@ -864,7 +864,7 @@ struct meta_data {
      * @return The property associated with the given key, if any.
      */
     [[nodiscard]] meta_prop prop(meta_any key) const {
-        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return *curr->id == key; }, node);
+        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return curr->id == key; }, node);
     }
 
     /**
@@ -983,7 +983,7 @@ struct meta_func {
      * @return The property associated with the given key, if any.
      */
     [[nodiscard]] meta_prop prop(meta_any key) const {
-        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return *curr->id == key; }, node);
+        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return curr->id == key; }, node);
     }
 
     /**
@@ -1491,7 +1491,7 @@ public:
      * @return The property associated with the given key, if any.
      */
     [[nodiscard]] meta_prop prop(meta_any key) const {
-        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return *curr->id == key; }, node);
+        return internal::meta_visit<&node_type::prop>([&key](const auto *curr) { return curr->id == key; }, node);
     }
 
     /**

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

@@ -36,8 +36,8 @@ struct meta_type_node;
 
 struct meta_prop_node {
     meta_prop_node * next;
-    const meta_any * const id;
-    meta_any * const value;
+    const meta_any &id;
+    meta_any &value;
 };