Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5684f3e0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Avoid unnecessary allocation in VectorImpl" into main

parents eb34156a e0ec952b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -463,7 +463,8 @@ void VectorImpl::_shrink(size_t where, size_t amount)
    size_t new_size;
    LOG_ALWAYS_FATAL_IF(__builtin_sub_overflow(mCount, amount, &new_size));

    if (new_size < (capacity() / 2)) {
    const size_t prev_capacity = capacity();
    if (new_size < (prev_capacity / 2) && prev_capacity > kMinVectorCapacity) {
        // NOTE: (new_size * 2) is safe because capacity didn't overflow and
        // new_size < (capacity / 2)).
        const size_t new_capacity = max(kMinVectorCapacity, new_size * 2);