diff options
Diffstat (limited to 'absl/container/inlined_vector.h')
-rw-r--r-- | absl/container/inlined_vector.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h index 90bb96e8..7c182342 100644 --- a/absl/container/inlined_vector.h +++ b/absl/container/inlined_vector.h @@ -167,11 +167,13 @@ class InlinedVector { // Creates an inlined vector by copying the contents of `other` using `alloc`. InlinedVector(const InlinedVector& other, const allocator_type& alloc) : storage_(alloc) { - if (IsMemcpyOk::value && !other.storage_.GetIsAllocated()) { + if (other.empty()) { + // Empty; nothing to do. + } else if (IsMemcpyOk::value && !other.storage_.GetIsAllocated()) { + // Memcpy-able and do not need allocation. storage_.MemcpyFrom(other.storage_); } else { - storage_.Initialize(IteratorValueAdapter<const_pointer>(other.data()), - other.size()); + storage_.InitFrom(other.storage_); } } |