mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Fixed PODArray
This commit is contained in:
parent
9ed791fd30
commit
8dd52f087e
@ -166,17 +166,6 @@ protected:
|
|||||||
return (stack_threshold > 0) && (allocated_bytes() <= stack_threshold);
|
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 <typename ... TAllocatorParams>
|
template <typename ... TAllocatorParams>
|
||||||
void reserveForNextSize(TAllocatorParams &&... allocator_params)
|
void reserveForNextSize(TAllocatorParams &&... allocator_params)
|
||||||
{
|
{
|
||||||
@ -441,7 +430,7 @@ public:
|
|||||||
template <typename U, typename ... TAllocatorParams>
|
template <typename U, typename ... TAllocatorParams>
|
||||||
void push_back(U && x, TAllocatorParams &&... allocator_params)
|
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<TAllocatorParams>(allocator_params)...);
|
this->reserveForNextSize(std::forward<TAllocatorParams>(allocator_params)...);
|
||||||
|
|
||||||
new (t_end()) T(std::forward<U>(x));
|
new (t_end()) T(std::forward<U>(x));
|
||||||
@ -454,7 +443,7 @@ public:
|
|||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void emplace_back(Args &&... args)
|
void emplace_back(Args &&... args)
|
||||||
{
|
{
|
||||||
if (unlikely(this->shouldReserveForNextSizeBeforeInsert()))
|
if (unlikely(this->c_end == this->c_end_of_storage))
|
||||||
this->reserveForNextSize();
|
this->reserveForNextSize();
|
||||||
|
|
||||||
new (t_end()) T(std::forward<Args>(args)...);
|
new (t_end()) T(std::forward<Args>(args)...);
|
||||||
|
Loading…
Reference in New Issue
Block a user