From e466d9252f6fef3cdc6e160f91c2b5f1334c2ae9 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Fri, 14 Aug 2020 12:12:57 +0200 Subject: [PATCH] view: rebind the view only when possible --- src/entt/entity/view.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/entt/entity/view.hpp b/src/entt/entity/view.hpp index dbedb18c3..d41760a74 100644 --- a/src/entt/entity/view.hpp +++ b/src/entt/entity/view.hpp @@ -579,6 +579,7 @@ public: */ template void each(Func func) const { + view = candidate(); ((std::get *>(pools) == view ? each(std::move(func)) : void()), ...); } @@ -618,6 +619,7 @@ public: * @return An iterable object to use to _visit_ the view. */ [[nodiscard]] auto proxy() const ENTT_NOEXCEPT { + view = candidate(); return view_proxy{begin(), end(), pools}; } @@ -678,12 +680,13 @@ public: template void chunked(Func func) const { using non_empty_type = type_list_cat_t, type_list>...>; + view = candidate(); iterate(std::move(func), non_empty_type{}); } private: const std::tuple *...> pools; - const sparse_set* view; + mutable const sparse_set* view; filter_type filter; };