From 15f0ab87e0f1864f6804b294a8e94a5ee31f75d7 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 28 Feb 2021 19:03:38 -0800 Subject: [PATCH] clang-tidy: use const references Found with performance-for-range-copy Signed-off-by: Rosen Penev --- src/Task.cpp | 8 ++++---- src/feedback.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Task.cpp b/src/Task.cpp index 3a20d02ff..8ab25c571 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -200,7 +200,7 @@ bool Task::has (const std::string& name) const std::vector Task::all () { std::vector all; - for (auto i : data) + for (const auto& i : data) all.push_back (i.first); return all; @@ -836,7 +836,7 @@ std::string Task::composeF4 () const std::string ff4 = "["; bool first = true; - for (auto it : data) + for (const auto& it : data) { // Orphans have no type, treat as string. std::string type = Task::attributes[it.first]; @@ -931,7 +931,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const out << "\"tags\":["; int count = 0; - for (auto i : tags) + for (const auto& i : tags) { if (count++) out << ','; @@ -970,7 +970,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const out << "\"depends\":["; int count = 0; - for (auto i : deps) + for (const auto& i : deps) { if (count++) out << ','; diff --git a/src/feedback.cpp b/src/feedback.cpp index b514dcb3d..2ed56e3ce 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -48,7 +48,7 @@ std::string taskIdentifiers (const std::vector & tasks) { std::vector identifiers; identifiers.reserve(tasks.size()); - for (auto task: tasks) + for (const auto& task: tasks) identifiers.push_back (task.identifier (true)); return join (", ", identifiers);