From 7f531e5e2d9e97b6ce9ddbbeb81397def98d3e3e Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 27 Jun 2023 12:34:21 +0200 Subject: [PATCH] view: further reduce instantiations --- src/entt/entity/view.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index 75b886a46..bb54e6c39 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -31,6 +31,13 @@ template return (!(filter[Index] && filter[Index]->contains(entt)) && ...); } +template +[[nodiscard]] auto fully_initialized(const std::array &filter) noexcept { + std::size_t pos{}; + for(; pos < N && filter[pos] != nullptr; ++pos) {} + return pos == N; +} + template [[nodiscard]] auto view_pack(const std::tuple value, const std::tuple excl, std::index_sequence) { const auto pools = std::tuple_cat(value, excl); @@ -454,8 +461,7 @@ public: * @return True if the view is fully initialized, false otherwise. */ [[nodiscard]] explicit operator bool() const noexcept { - return std::apply([](const auto *...curr) { return ((curr != nullptr) && ...); }, pools) - && std::apply([](const auto *...curr) { return ((curr != nullptr) && ...); }, filter); + return std::apply([](const auto *...curr) { return ((curr != nullptr) && ...); }, pools) && internal::fully_initialized(filter); } /**