runtime_view: slightly optimized iterators
This commit is contained in:
@@ -23,7 +23,8 @@ namespace internal {
|
||||
template<typename Type>
|
||||
class runtime_view_iterator final {
|
||||
[[nodiscard]] bool valid() const {
|
||||
return std::all_of(pools->begin(), pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); })
|
||||
return (!tombstone_check || *it != tombstone)
|
||||
&& std::all_of(++pools->begin(), pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); })
|
||||
&& std::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); });
|
||||
}
|
||||
|
||||
@@ -40,7 +41,8 @@ public:
|
||||
runtime_view_iterator(const std::vector<const Type *> &cpools, const std::vector<const Type *> &ignore, iterator_type curr) ENTT_NOEXCEPT
|
||||
: pools{&cpools},
|
||||
filter{&ignore},
|
||||
it{curr} {
|
||||
it{curr},
|
||||
tombstone_check{pools->size() == 1u && (*pools)[0u]->policy() == deletion_policy::in_place} {
|
||||
if(it != (*pools)[0]->end() && !valid()) {
|
||||
++(*this);
|
||||
}
|
||||
@@ -86,6 +88,7 @@ private:
|
||||
const std::vector<const Type *> *pools;
|
||||
const std::vector<const Type *> *filter;
|
||||
iterator_type it;
|
||||
bool tombstone_check;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
Reference in New Issue
Block a user