summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Aaron Jacobs <jacobsa@google.com>2023-03-27 14:01:23 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-03-27 14:02:29 -0700
commit0dc94309d367001176962db4ed3dc450a6448b31 (patch)
tree8168d68c06e692ad1dac85252f06f134955ba9cf
parent0390de901b330763497f7b0d68b4b65876cdcd55 (diff)
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
-rw-r--r--absl/container/internal/inlined_vector.h11
1 files changed, 3 insertions, 8 deletions
diff --git a/absl/container/internal/inlined_vector.h b/absl/container/internal/inlined_vector.h
index 3cd69b55..6397db48 100644
--- a/absl/container/internal/inlined_vector.h
+++ b/absl/container/internal/inlined_vector.h
@@ -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;
}