storage: small improvement for shrink_to_size
This commit is contained in:
2
TODO
2
TODO
@@ -34,9 +34,9 @@ TODO:
|
||||
* organizer: view/storage only based model, no registry
|
||||
* introduce a way to inject stl from outside too
|
||||
* redesign snapshot as a whole
|
||||
* storage: trivial destructor on exit (ie shrink_to_size) and clear/pop_all
|
||||
* use the value type mixin more in the test suite to reduce the number of utility types
|
||||
* explore "runtime" mode for hashed string where the source is copied internally
|
||||
* swap_only/swap_and_pop/in_place_pop can (should?) accept the entity
|
||||
* we can likely improve storage::pop for trivially destructible non in_place_delete types
|
||||
* storage: shrink_to_fit does not work with reentrant destructor?
|
||||
* test trivially_destructible optimization
|
||||
|
||||
@@ -261,13 +261,15 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
|
||||
const auto from = (sz + traits_type::page_size - 1u) / traits_type::page_size;
|
||||
allocator_type allocator{get_allocator()};
|
||||
|
||||
for(auto pos = sz, length = base_type::size(); pos < length; ++pos) {
|
||||
if constexpr(traits_type::in_place_delete) {
|
||||
if(base_type::data()[pos] != tombstone) {
|
||||
if constexpr(!std::is_trivially_destructible_v<element_type>) {
|
||||
for(auto pos = sz, length = base_type::size(); pos < length; ++pos) {
|
||||
if constexpr(traits_type::in_place_delete) {
|
||||
if(base_type::data()[pos] != tombstone) {
|
||||
alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
|
||||
}
|
||||
} else {
|
||||
alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
|
||||
}
|
||||
} else {
|
||||
alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user