From a8a86ba09050ccab15fa444f768bcea5fa5b192b Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 25 Mar 2024 11:18:35 +0100 Subject: [PATCH] sparse_set: avoid using scoped iterators internally when sorting --- src/entt/entity/sparse_set.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index fbe4b20cc..b4704bcde 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -1025,7 +1025,7 @@ public: */ template void sort(Compare compare, Sort algo = Sort{}, Args &&...args) { - sort_n(static_cast(end() - begin(0)), std::move(compare), std::move(algo), std::forward(args)...); + sort_n((mode == deletion_policy::swap_only) ? head : packed.size(), std::move(compare), std::move(algo), std::forward(args)...); } /** @@ -1044,7 +1044,7 @@ public: template iterator sort_as(It first, It last) { ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed"); - auto it = begin(0); + auto it = (mode == deletion_policy::swap_only) ? (end() - static_cast(head)) : begin(); for(const auto other = end(); (it != other) && (first != last); ++first) { if(const auto curr = *first; contains(curr)) {