diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SplitVector.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h index 19b854f5a..081c7cbfb 100644 --- a/src/SplitVector.h +++ b/src/SplitVector.h @@ -191,7 +191,7 @@ public: } RoomFor(insertLength); GapTo(position); - std::fill(body.data() + part1Length, body.data() + part1Length + insertLength, v); + std::fill_n(body.data() + part1Length, insertLength, v); lengthBody += insertLength; part1Length += insertLength; gapLength -= insertLength; @@ -210,10 +210,8 @@ public: } RoomFor(insertLength); GapTo(position); - for (ptrdiff_t elem = part1Length; elem < part1Length + insertLength; elem++) { - T emptyOne = {}; - body[elem] = std::move(emptyOne); - } + T *ptr = body.data() + part1Length; + std::uninitialized_value_construct_n(ptr, insertLength); lengthBody += insertLength; part1Length += insertLength; gapLength -= insertLength; @@ -238,7 +236,7 @@ public: } RoomFor(insertLength); GapTo(positionToInsert); - std::copy(s + positionFrom, s + positionFrom + insertLength, body.data() + part1Length); + std::copy_n(s + positionFrom, insertLength, body.data() + part1Length); lengthBody += insertLength; part1Length += insertLength; gapLength -= insertLength; @@ -284,11 +282,11 @@ public: if (range1Length > part1AfterPosition) range1Length = part1AfterPosition; } - std::copy(body.data() + position, body.data() + position + range1Length, buffer); + std::copy_n(body.data() + position, range1Length, buffer); buffer += range1Length; position = position + range1Length + gapLength; const ptrdiff_t range2Length = retrieveLength - range1Length; - std::copy(body.data() + position, body.data() + position + range2Length, buffer); + std::copy_n(body.data() + position, range2Length, buffer); } /// Compact the buffer and return a pointer to the first element. |