mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-25 21:27:19 +02:00
clang-tidy: add missing reserve calls
Found with performance-inefficient-vector-operation Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
3cafb5257e
commit
d0c4350c2f
4 changed files with 6 additions and 0 deletions
|
@ -196,6 +196,7 @@ void Hooks::onExit () const
|
|||
|
||||
// Convert to a vector of strings.
|
||||
std::vector <std::string> input;
|
||||
input.reserve(tasks.size());
|
||||
for (auto& t : tasks)
|
||||
input.push_back (t.composeJSON ());
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& ma
|
|||
auto blocking = dependencyGetBlocking (task);
|
||||
|
||||
std::vector <int> blocking_ids;
|
||||
blocking_ids.reserve(blocking.size());
|
||||
for (auto& i : blocking)
|
||||
blocking_ids.push_back (i.id);
|
||||
|
||||
|
@ -129,6 +130,7 @@ void ColumnDepends::render (
|
|||
auto blocking = dependencyGetBlocking (task);
|
||||
|
||||
std::vector <int> blocking_ids;
|
||||
blocking_ids.reserve(blocking.size());
|
||||
for (const auto& t : blocking)
|
||||
blocking_ids.push_back (t.id);
|
||||
|
||||
|
|
|
@ -236,6 +236,7 @@ int CmdUUIDs::execute (std::string& output)
|
|||
filter.subset (filtered);
|
||||
|
||||
std::vector <std::string> uuids;
|
||||
uuids.reserve(filtered.size());
|
||||
for (auto& task : filtered)
|
||||
uuids.push_back (task.get ("uuid"));
|
||||
|
||||
|
@ -273,6 +274,7 @@ int CmdCompletionUuids::execute (std::string& output)
|
|||
filter.subset (filtered);
|
||||
|
||||
std::vector <std::string> uuids;
|
||||
uuids.reserve(filtered.size());
|
||||
for (auto& task : filtered)
|
||||
uuids.push_back (task.get ("uuid"));
|
||||
|
||||
|
|
|
@ -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::vector <std::string> identifiers;
|
||||
identifiers.reserve(tasks.size());
|
||||
for (auto task: tasks)
|
||||
identifiers.push_back (task.identifier (true));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue