From 7f86b29aa9631712a7e5312c01186a9c9e80e1fd Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 27 Sep 2019 20:34:25 -0700 Subject: [PATCH] [clang-tidy] Reserve memory for vector loop Found with performance-inefficient-vector-operation Signed-off-by: Rosen Penev --- src/Hooks.cpp | 1 + src/feedback.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 496104107..a4929a07e 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -196,6 +196,7 @@ void Hooks::onExit () const // Convert to a vector of strings. std::vector input; + input.reserve(tasks.size()); for (auto& t : tasks) input.push_back (t.composeJSON ()); diff --git a/src/feedback.cpp b/src/feedback.cpp index 19e6c078f..781a3eff4 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -47,6 +47,7 @@ static void countTasks (const std::vector &, const std::string&, int&, int std::string taskIdentifiers (const std::vector & tasks) { std::vector identifiers; + identifiers.reserve(tasks.size()); for (const auto& task: tasks) identifiers.push_back (task.identifier (true));