From 46051d8aa40c69e17e3e4d108bc2fa8d5694de75 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 28 Apr 2021 18:56:12 +1000 Subject: Use copy instead of loop and rely on make_unique zeroing result. --- src/PositionCache.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 0a9ef259a..a3e8e74f8 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -179,11 +179,8 @@ void LineLayout::SetLineStart(int line, int start) { if ((line >= lenLineStarts) && (line != 0)) { const int newMaxLines = line + 20; std::unique_ptr newLineStarts = std::make_unique(newMaxLines); - for (int i = 0; i < newMaxLines; i++) { - if (i < lenLineStarts) - newLineStarts[i] = lineStarts[i]; - else - newLineStarts[i] = 0; + if (lenLineStarts) { + std::copy(lineStarts.get(), lineStarts.get() + lenLineStarts, newLineStarts.get()); } lineStarts = std::move(newLineStarts); lenLineStarts = newMaxLines; -- cgit v1.2.3