diff --git a/src/Common/PODArray.h b/src/Common/PODArray.h index 579d500e6df..aa7454badd6 100644 --- a/src/Common/PODArray.h +++ b/src/Common/PODArray.h @@ -166,17 +166,6 @@ protected: return (stack_threshold > 0) && (allocated_bytes() <= stack_threshold); } - bool shouldReserveForNextSizeBeforeInsert() const - { - /** end_of_storage = left_padding + (start + elements_size * ELEMENT_SIZE). - * end = start + elements_size * ELEMENT_SIZE - * We use end + ELEMENT_SIZE >= end_of_storage because it - * It is not safe to use end == end_of_storage here because left_padding - * is not always multiple of ELEMENT_SIZE. - */ - return (c_end + ELEMENT_SIZE) >= c_end_of_storage; - } - template void reserveForNextSize(TAllocatorParams &&... allocator_params) { @@ -441,7 +430,7 @@ public: template void push_back(U && x, TAllocatorParams &&... allocator_params) { - if (unlikely(this->shouldReserveForNextSizeBeforeInsert())) + if (unlikely(this->c_end == this->c_end_of_storage)) this->reserveForNextSize(std::forward(allocator_params)...); new (t_end()) T(std::forward(x)); @@ -454,7 +443,7 @@ public: template void emplace_back(Args &&... args) { - if (unlikely(this->shouldReserveForNextSizeBeforeInsert())) + if (unlikely(this->c_end == this->c_end_of_storage)) this->reserveForNextSize(); new (t_end()) T(std::forward(args)...);