Browse Source

view: drop unnecessary member

Michele Caini 1 year ago
parent
commit
d67fd1e72c
2 changed files with 7 additions and 8 deletions
  1. 0 1
      TODO
  2. 7 7
      src/entt/entity/view.hpp

+ 0 - 1
TODO

@@ -34,6 +34,5 @@ TODO:
 * more test around views and storage entity - ie view ::back
 * more test around views and storage entity - ie view ::back
 * table: pop back to support swap and pop, single column access, empty type optimization
 * table: pop back to support swap and pop, single column access, empty type optimization
 * checkout tools workflow
 * checkout tools workflow
-* meta: avoid unnecessary copies of iterators with meta containers
 * review constrained noexcept-ness (ie sigh)
 * review constrained noexcept-ness (ie sigh)
 * offer 16b from meta_traits to users or change type
 * offer 16b from meta_traits to users or change type

+ 7 - 7
src/entt/entity/view.hpp

@@ -60,6 +60,10 @@ class view_iterator final {
                && internal::none_of(pools.begin() + Get, pools.end(), entt);
                && internal::none_of(pools.begin() + Get, pools.end(), entt);
     }
     }
 
 
+    void seek_next() {
+        for(constexpr iterator_type sentinel{}; it != sentinel && !valid(*it); ++it) {}
+    }
+
 public:
 public:
     using value_type = typename iterator_traits::value_type;
     using value_type = typename iterator_traits::value_type;
     using pointer = typename iterator_traits::pointer;
     using pointer = typename iterator_traits::pointer;
@@ -69,22 +73,19 @@ public:
 
 
     constexpr view_iterator() noexcept
     constexpr view_iterator() noexcept
         : it{},
         : it{},
-          last{},
           pools{},
           pools{},
           index{} {}
           index{} {}
 
 
     view_iterator(iterator_type first, std::array<const Type *, Size> value, const std::size_t idx) noexcept
     view_iterator(iterator_type first, std::array<const Type *, Size> value, const std::size_t idx) noexcept
         : it{first},
         : it{first},
-          last{value[idx]->end()},
           pools{value},
           pools{value},
           index{idx} {
           index{idx} {
-        while(it != last && !valid(*it)) {
-            ++it;
-        }
+        seek_next();
     }
     }
 
 
     view_iterator &operator++() noexcept {
     view_iterator &operator++() noexcept {
-        while(++it != last && !valid(*it)) {}
+        ++it;
+        seek_next();
         return *this;
         return *this;
     }
     }
 
 
@@ -106,7 +107,6 @@ public:
 
 
 private:
 private:
     iterator_type it;
     iterator_type it;
-    iterator_type last;
     std::array<const Type *, Size> pools;
     std::array<const Type *, Size> pools;
     std::size_t index;
     std::size_t index;
 };
 };