@@ -389,12 +389,12 @@ class PODArray : public PODArrayBase<sizeof(T), initial_bytes, TAllocator, pad_r
389389 template <typename U, typename ... TAllocatorParams>
390390 void add_num_element (U&& x, uint32_t num, TAllocatorParams&&... allocator_params) {
391391 if (num != 0 ) {
392- const auto new_end = this -> c_end + this ->byte_size (num);
393- if (UNLIKELY (new_end > this ->c_end_of_storage )) {
392+ const auto growth_size = this ->byte_size (num);
393+ if (UNLIKELY (this -> c_end + growth_size > this ->c_end_of_storage )) {
394394 this ->reserve (this ->size () + num);
395395 }
396396 std::fill (t_end (), t_end () + num, x);
397- this ->c_end = new_end ;
397+ this ->c_end = this -> c_end + growth_size ;
398398 }
399399 }
400400
@@ -420,7 +420,9 @@ class PODArray : public PODArrayBase<sizeof(T), initial_bytes, TAllocator, pad_r
420420 */
421421 template <typename ... Args>
422422 void emplace_back (Args&&... args) {
423- if (UNLIKELY (this ->c_end == this ->c_end_of_storage )) this ->reserve_for_next_size ();
423+ if (UNLIKELY (this ->c_end + sizeof (T) > this ->c_end_of_storage )) {
424+ this ->reserve_for_next_size ();
425+ }
424426
425427 new (t_end ()) T (std::forward<Args>(args)...);
426428 this ->c_end += this ->byte_size (1 );
@@ -457,22 +459,6 @@ class PODArray : public PODArrayBase<sizeof(T), initial_bytes, TAllocator, pad_r
457459 this ->c_end += bytes_to_copy;
458460 }
459461
460- template <typename It1, typename It2>
461- void insert (iterator it, It1 from_begin, It2 from_end) {
462- insert_prepare (from_begin, from_end);
463-
464- size_t bytes_to_copy = this ->byte_size (from_end - from_begin);
465- size_t bytes_to_move = (end () - it) * sizeof (T);
466-
467- if (UNLIKELY (bytes_to_move))
468- memcpy (this ->c_end + bytes_to_copy - bytes_to_move, this ->c_end - bytes_to_move,
469- bytes_to_move);
470-
471- memcpy (this ->c_end - bytes_to_move, reinterpret_cast <const void *>(&*from_begin),
472- bytes_to_copy);
473- this ->c_end += bytes_to_copy;
474- }
475-
476462 template <typename It1, typename It2>
477463 void insert_assume_reserved (It1 from_begin, It2 from_end) {
478464 size_t bytes_to_copy = this ->byte_size (from_end - from_begin);
0 commit comments