Procházet zdrojové kódy

meta: cleanup/reuse internal code

Michele Caini před 1 rokem
rodič
revize
50db6f2193
2 změnil soubory, kde provedl 5 přidání a 25 odebrání
  1. 0 2
      TODO
  2. 5 23
      src/entt/meta/meta.hpp

+ 0 - 2
TODO

@@ -44,6 +44,4 @@ TODO:
 * suppress -Wself-move on CI with g++13
 * view and view iterator specializations for multi, single and filtered elements
 * organizer support to groups
-* meta factory: share code and cleanup after the map-to-vector rework
 * meta range: move id to meta objects and return plain types (?), then remove id from meta base and meta ctor too
-* reuse find_member/find_overload ie in meta_type::invoke

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

@@ -1175,22 +1175,8 @@ class meta_type {
 
                     if(const auto &info = other.info(); info == type.info()) {
                         ++match;
-                    } else {
-                        bool can_continue = type.node.conversion_helper && other.node.conversion_helper;
-
-                        if(!can_continue && type.node.details) {
-                            for(std::size_t idx{}, last = type.node.details->base.size(); !can_continue && idx != last; ++idx) {
-                                can_continue = (type.node.details->base[idx].type == info.hash());
-                            }
-
-                            for(std::size_t idx{}, last = type.node.details->conv.size(); !can_continue && idx != last; ++idx) {
-                                can_continue = (type.node.details->conv[idx].type == info.hash());
-                            }
-                        }
-
-                        if(!can_continue) {
-                            break;
-                        }
+                    } else if(!(type.node.conversion_helper && other.node.conversion_helper) && !(type.node.details && (internal::find_member<&internal::meta_base_node::type>(type.node.details->base, info.hash()) || internal::find_member<&internal::meta_conv_node::type>(type.node.details->conv, info.hash())))) {
+                        break;
                     }
                 }
                 // NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
@@ -1516,13 +1502,9 @@ public:
      */
     meta_any invoke(const id_type id, meta_handle instance, meta_any *const args, const size_type sz) const {
         if(node.details) {
-            for(auto &&elem: node.details->func) {
-                if(elem.id == id) {
-                    if(const auto *candidate = lookup(args, sz, instance && (instance->data() == nullptr), [curr = &elem]() mutable { return curr ? std::exchange(curr, curr->next.get()) : nullptr; }); candidate) {
-                        return candidate->invoke(*ctx, meta_handle{*ctx, std::move(instance)}, args);
-                    }
-
-                    break;
+            if(auto *elem = internal::find_member<&internal::meta_func_node::id>(node.details->func, id); elem != nullptr) {
+                if(const auto *candidate = lookup(args, sz, instance && (instance->data() == nullptr), [curr = elem]() mutable { return curr ? std::exchange(curr, curr->next.get()) : nullptr; }); candidate) {
+                    return candidate->invoke(*ctx, meta_handle{*ctx, std::move(instance)}, args);
                 }
             }
         }