Skip to content

Commit

Permalink
storage: try to address wrong code coverage results by lcov2
Browse files Browse the repository at this point in the history
  • Loading branch information
skypjack committed Dec 23, 2024
1 parent 15fe6fe commit 5a2da65
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/entt/entity/storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
payload.resize(from);
}

void swap_at(const std::size_t from, const std::size_t to) {
using std::swap;
swap(element_at(from), element_at(to));
}

void move_to(const std::size_t from, const std::size_t to) {
auto &elem = element_at(from);
allocator_type allocator{get_allocator()};
entt::uninitialized_construct_using_allocator(to_address(assure_at_least(to)), allocator, std::move(elem));
alloc_traits::destroy(allocator, std::addressof(elem));
}

private:
[[nodiscard]] const void *get_at(const std::size_t pos) const final {
return std::addressof(element_at(pos));
Expand All @@ -309,20 +321,10 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
ENTT_ASSERT((from + 1u) && !is_pinned_type, "Pinned type");

if constexpr(!is_pinned_type) {
auto &elem = element_at(from);

if constexpr(traits_type::in_place_delete) {
if(base_type::operator[](to) == tombstone) {
allocator_type allocator{get_allocator()};
entt::uninitialized_construct_using_allocator(to_address(assure_at_least(to)), allocator, std::move(elem));
alloc_traits::destroy(allocator, std::addressof(elem));
} else {
using std::swap;
swap(elem, element_at(to));
}
(base_type::operator[](to) == tombstone) ? move_to(from, to) : swap_with(from, to);
} else {
using std::swap;
swap(elem, element_at(to));
swap_with(from, to);
}
}
}
Expand Down

0 comments on commit 5a2da65

Please sign in to comment.