Skip to content

Commit

Permalink
#161 resize instead of emplace in for-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Oct 8, 2021
1 parent 4486e85 commit ff1eafe
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/checkpoint/container/vector_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ void constructVectorDataReconstruct(
typename ReconstructorTraits<T>::template isReconstructibleType<T>* = nullptr
) {
Allocated<T> const allocated;
for (SerialSizeType i = 0; i < vec_size; ++i) {
auto& t = T::reconstruct(allocated.buf);
vec.emplace_back(std::move(t));
}
auto& t = T::reconstruct(allocated.buf);
vec.resize(vec_size, t);
}

template <typename T, typename VectorAllocator>
Expand All @@ -124,11 +122,9 @@ void constructVectorDataReconstruct(
typename ReconstructorTraits<T>::template isNonIntReconstructibleType<T>* = nullptr
) {
Allocated<T> const allocated;
for (SerialSizeType i = 0; i < vec_size; ++i) {
T* t = nullptr;
reconstruct(t, allocated.buf);
vec.emplace_back(std::move(*t));
}
T* t = nullptr;
reconstruct(t, allocated.buf);
vec.resize(vec_size, *t);
}

template <typename T, typename VectorAllocator>
Expand Down

0 comments on commit ff1eafe

Please sign in to comment.