minor libutils improvements

This commit is contained in:
Mathias Agopian
2024-05-14 13:22:38 -07:00
committed by Mathias Agopian
parent 499939ed3c
commit c93aa4c90d
2 changed files with 21 additions and 1 deletions
@@ -299,6 +299,16 @@ public:
}
}
UTILS_NOINLINE
void shrink_to_fit() {
if (size() < capacity()) {
FixedCapacityVector t(construct_with_capacity, size(), allocator());
t.mSize = size();
std::uninitialized_move(begin(), end(), t.begin());
this->swap(t);
}
}
private:
enum construct_with_capacity_tag{ construct_with_capacity };