Skip to content

Commit 5a2da65

Browse files
committed
storage: try to address wrong code coverage results by lcov2
1 parent 15fe6fe commit 5a2da65

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/entt/entity/storage.hpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,18 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
298298
payload.resize(from);
299299
}
300300

301+
void swap_at(const std::size_t from, const std::size_t to) {
302+
using std::swap;
303+
swap(element_at(from), element_at(to));
304+
}
305+
306+
void move_to(const std::size_t from, const std::size_t to) {
307+
auto &elem = element_at(from);
308+
allocator_type allocator{get_allocator()};
309+
entt::uninitialized_construct_using_allocator(to_address(assure_at_least(to)), allocator, std::move(elem));
310+
alloc_traits::destroy(allocator, std::addressof(elem));
311+
}
312+
301313
private:
302314
[[nodiscard]] const void *get_at(const std::size_t pos) const final {
303315
return std::addressof(element_at(pos));
@@ -309,20 +321,10 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
309321
ENTT_ASSERT((from + 1u) && !is_pinned_type, "Pinned type");
310322

311323
if constexpr(!is_pinned_type) {
312-
auto &elem = element_at(from);
313-
314324
if constexpr(traits_type::in_place_delete) {
315-
if(base_type::operator[](to) == tombstone) {
316-
allocator_type allocator{get_allocator()};
317-
entt::uninitialized_construct_using_allocator(to_address(assure_at_least(to)), allocator, std::move(elem));
318-
alloc_traits::destroy(allocator, std::addressof(elem));
319-
} else {
320-
using std::swap;
321-
swap(elem, element_at(to));
322-
}
325+
(base_type::operator[](to) == tombstone) ? move_to(from, to) : swap_with(from, to);
323326
} else {
324-
using std::swap;
325-
swap(elem, element_at(to));
327+
swap_with(from, to);
326328
}
327329
}
328330
}

0 commit comments

Comments
 (0)