Browse Source

minor changes

Michele Caini 6 years ago
parent
commit
eb252321a7
2 changed files with 5 additions and 3 deletions
  1. 4 2
      src/entt/entity/observer.hpp
  2. 1 1
      src/entt/entity/sparse_set.hpp

+ 4 - 2
src/entt/entity/observer.hpp

@@ -176,7 +176,8 @@ class basic_observer {
         template<std::size_t Index>
         static void maybe_valid_if(basic_observer *obs, const basic_registry<Entity> &reg, const Entity entt) {
             if(reg.template has<Require...>(entt) && !(reg.template has<Reject>(entt) || ...)) {
-                (obs->view.has(entt) ? obs->view.get(entt) : obs->view.construct(entt)) |= (1 << Index);
+                auto *comp = obs->view.try_get(entt);
+                (comp ? *comp : obs->view.construct(entt)) |= (1 << Index);
             }
         }
 
@@ -210,7 +211,8 @@ class basic_observer {
             if(reg.template has<AllOf...>(entt) && !(reg.template has<NoneOf>(entt) || ...)
                     && reg.template has<Require...>(entt) && !(reg.template has<Reject>(entt) || ...))
             {
-                (obs->view.has(entt) ? obs->view.get(entt) : obs->view.construct(entt)) |= (1 << Index);
+                auto *comp = obs->view.try_get(entt);
+                (comp ? *comp : obs->view.construct(entt)) |= (1 << Index);
             }
         }
 

+ 1 - 1
src/entt/entity/sparse_set.hpp

@@ -47,7 +47,7 @@ class sparse_set {
     using traits_type = entt_traits<Entity>;
 
     static_assert(ENTT_PAGE_SIZE && ((ENTT_PAGE_SIZE & (ENTT_PAGE_SIZE - 1)) == 0));
-    static constexpr auto entt_per_page = ENTT_PAGE_SIZE / sizeof(typename entt_traits<Entity>::entity_type);
+    static constexpr auto entt_per_page = ENTT_PAGE_SIZE / sizeof(typename traits_type::entity_type);
 
     class iterator {
         friend class sparse_set<Entity>;