sparse_set: avoid using scoped iterators internally when sorting

This commit is contained in:
Michele Caini
2024-03-25 11:18:35 +01:00
parent 430d1dda86
commit a8a86ba090

View File

@@ -1025,7 +1025,7 @@ public:
*/
template<typename Compare, typename Sort = std_sort, typename... Args>
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
sort_n(static_cast<size_type>(end() - begin(0)), std::move(compare), std::move(algo), std::forward<Args>(args)...);
sort_n((mode == deletion_policy::swap_only) ? head : packed.size(), std::move(compare), std::move(algo), std::forward<Args>(args)...);
}
/**
@@ -1044,7 +1044,7 @@ public:
template<typename It>
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<typename iterator::difference_type>(head)) : begin();
for(const auto other = end(); (it != other) && (first != last); ++first) {
if(const auto curr = *first; contains(curr)) {