Skip to content

Commit

Permalink
multi-component view no longer uses sparse_set<...>::extent()
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Aug 25, 2019
1 parent 26e3265 commit c927760
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/entt/entity/view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,18 @@ class basic_view {
class iterator {
friend class basic_view<Entity, Component...>;

using extent_type = typename sparse_set<Entity>::size_type;

iterator(unchecked_type other, underlying_iterator_type first, underlying_iterator_type last) ENTT_NOEXCEPT
: unchecked{other},
begin{first},
end{last},
extent{min(std::make_index_sequence<other.size()>{})}
end{last}
{
if(begin != end && !valid()) {
++(*this);
}
}

template<auto... Indexes>
extent_type min(std::index_sequence<Indexes...>) const ENTT_NOEXCEPT {
return std::min({ std::get<Indexes>(unchecked)->extent()... });
}

bool valid() const ENTT_NOEXCEPT {
const auto entt = *begin;
const auto sz = size_type(to_integer(entt) & traits_type::entity_mask);

return sz < extent && std::all_of(unchecked.cbegin(), unchecked.cend(), [entt](const sparse_set<Entity> *view) {
return std::all_of(unchecked.cbegin(), unchecked.cend(), [entt = *begin](const sparse_set<Entity> *view) {
return view->has(entt);
});
}
Expand Down Expand Up @@ -141,7 +130,6 @@ class basic_view {
unchecked_type unchecked;
underlying_iterator_type begin;
underlying_iterator_type end;
extent_type extent;
};

// we could use pool_type<Component> *..., but vs complains about it and refuses to compile for unknown reasons (likely a bug)
Expand Down

0 comments on commit c927760

Please sign in to comment.