Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions be/src/vec/common/pod_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ class PODArray : public PODArrayBase<sizeof(T), initial_bytes, TAllocator, pad_r
template <typename U, typename... TAllocatorParams>
void add_num_element(U&& x, uint32_t num, TAllocatorParams&&... allocator_params) {
if (num != 0) {
const auto new_end = this->c_end + this->byte_size(num);
if (UNLIKELY(new_end > this->c_end_of_storage)) {
const auto growth_size = this->byte_size(num);
if (UNLIKELY(this->c_end + growth_size > this->c_end_of_storage)) {
this->reserve(this->size() + num);
}
std::fill(t_end(), t_end() + num, x);
this->c_end = new_end;
this->c_end = this->c_end + growth_size;
}
}

Expand All @@ -420,7 +420,9 @@ class PODArray : public PODArrayBase<sizeof(T), initial_bytes, TAllocator, pad_r
*/
template <typename... Args>
void emplace_back(Args&&... args) {
if (UNLIKELY(this->c_end == this->c_end_of_storage)) this->reserve_for_next_size();
if (UNLIKELY(this->c_end + sizeof(T) > this->c_end_of_storage)) {
this->reserve_for_next_size();
}

new (t_end()) T(std::forward<Args>(args)...);
this->c_end += this->byte_size(1);
Expand Down Expand Up @@ -457,22 +459,6 @@ class PODArray : public PODArrayBase<sizeof(T), initial_bytes, TAllocator, pad_r
this->c_end += bytes_to_copy;
}

template <typename It1, typename It2>
void insert(iterator it, It1 from_begin, It2 from_end) {
insert_prepare(from_begin, from_end);

size_t bytes_to_copy = this->byte_size(from_end - from_begin);
size_t bytes_to_move = (end() - it) * sizeof(T);

if (UNLIKELY(bytes_to_move))
memcpy(this->c_end + bytes_to_copy - bytes_to_move, this->c_end - bytes_to_move,
bytes_to_move);

memcpy(this->c_end - bytes_to_move, reinterpret_cast<const void*>(&*from_begin),
bytes_to_copy);
this->c_end += bytes_to_copy;
}

template <typename It1, typename It2>
void insert_assume_reserved(It1 from_begin, It2 from_end) {
size_t bytes_to_copy = this->byte_size(from_end - from_begin);
Expand Down
Loading
Loading