[clang-tidy] Reserve memory for vector loop
Found with performance-inefficient-vector-operation Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
committed by
Paul Beckingham
parent
ab170e34df
commit
7f86b29aa9
@@ -196,6 +196,7 @@ void Hooks::onExit () const
|
|||||||
|
|
||||||
// Convert to a vector of strings.
|
// Convert to a vector of strings.
|
||||||
std::vector <std::string> input;
|
std::vector <std::string> input;
|
||||||
|
input.reserve(tasks.size());
|
||||||
for (auto& t : tasks)
|
for (auto& t : tasks)
|
||||||
input.push_back (t.composeJSON ());
|
input.push_back (t.composeJSON ());
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ static void countTasks (const std::vector <Task>&, const std::string&, int&, int
|
|||||||
std::string taskIdentifiers (const std::vector <Task>& tasks)
|
std::string taskIdentifiers (const std::vector <Task>& tasks)
|
||||||
{
|
{
|
||||||
std::vector <std::string> identifiers;
|
std::vector <std::string> identifiers;
|
||||||
|
identifiers.reserve(tasks.size());
|
||||||
for (const auto& task: tasks)
|
for (const auto& task: tasks)
|
||||||
identifiers.push_back (task.identifier (true));
|
identifiers.push_back (task.identifier (true));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user