From ff1eafe535010d5c27a6d79a7366d41c9eb5b8ee Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Sat, 26 Jun 2021 20:44:32 +0200 Subject: [PATCH] #161 resize instead of emplace in for-loop --- src/checkpoint/container/vector_serialize.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/checkpoint/container/vector_serialize.h b/src/checkpoint/container/vector_serialize.h index b5966826..02ef4a9d 100644 --- a/src/checkpoint/container/vector_serialize.h +++ b/src/checkpoint/container/vector_serialize.h @@ -112,10 +112,8 @@ void constructVectorDataReconstruct( typename ReconstructorTraits::template isReconstructibleType* = nullptr ) { Allocated 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 @@ -124,11 +122,9 @@ void constructVectorDataReconstruct( typename ReconstructorTraits::template isNonIntReconstructibleType* = nullptr ) { Allocated 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