Commit 0dc94309 by Aaron Jacobs Committed by Copybara-Service

inlined_vector: destroy all types with trivial destructors efficiently.

There's no reason to require the type to be trivially
copy-constructible/assignable in order to avoid running destructors—those
traits have nothing to do with destruction.

PiperOrigin-RevId: 519822201
Change-Id: I2ed7bbb53f0c1a512017115ff29fb27a24c6b11a
parent 0390de90
......@@ -374,15 +374,10 @@ class Storage {
}
// Fast path: if no destructors need to be run and we know the allocator
// doesn't do anything fancy, then all we need to do is allocate (and maybe
// not even that).
//
// TODO(b/274984172): the conditions on copy constructibility/assignability
// are unnecessary, and are here only for historical reasons. Remove them.
// doesn't do anything fancy, then all we need to do is deallocate (and
// maybe not even that).
if (absl::is_trivially_destructible<ValueType<A>>::value &&
std::is_same<A, std::allocator<ValueType<A>>>::value &&
absl::is_trivially_copy_constructible<ValueType<A>>::value &&
absl::is_trivially_copy_assignable<ValueType<A>>::value) {
std::is_same<A, std::allocator<ValueType<A>>>::value) {
DeallocateIfAllocated();
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment