From 3f57c0a515bfa13de2ee1e5959cbfe47a2357b00 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 13 Dec 2020 20:21:34 -0800 Subject: [PATCH] VImage: reserve vector before push_back loop Avoids unnecessary resizes. Found with clang-tidy's performance-inefficient-vector-operation Signed-off-by: Rosen Penev --- cplusplus/VImage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cplusplus/VImage.cpp b/cplusplus/VImage.cpp index 49b006a4..01e1a6f3 100644 --- a/cplusplus/VImage.cpp +++ b/cplusplus/VImage.cpp @@ -767,6 +767,7 @@ std::vector VImage::bandsplit( VOption *options ) const { std::vector b; + b.reserve(bands()); for( int i = 0; i < bands(); i++ ) b.push_back( extract_band( i ) );