mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-10 13:10:37 +02:00
convert manual loops to std::count_if
Simpler and generates less assembly. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
62399239ca
commit
73575f8d88
3 changed files with 4 additions and 18 deletions
|
@ -70,17 +70,11 @@ int CmdStats::execute (std::string& output)
|
|||
|
||||
// Count the undo transactions.
|
||||
std::vector <std::string> undoTxns = Context::getContext ().tdb2.undo.get_lines ();
|
||||
int undoCount = 0;
|
||||
for (auto& tx : undoTxns)
|
||||
if (tx == "---")
|
||||
++undoCount;
|
||||
int undoCount = std::count(undoTxns.begin(), undoTxns.end(), "---");
|
||||
|
||||
// Count the backlog transactions.
|
||||
std::vector <std::string> backlogTxns = Context::getContext ().tdb2.backlog.get_lines ();
|
||||
int backlogCount = 0;
|
||||
for (auto& tx : backlogTxns)
|
||||
if (tx[0] == '{')
|
||||
++backlogCount;
|
||||
int backlogCount = std::count_if(backlogTxns.begin(), backlogTxns.end(), [](const auto& tx){ return tx.front() == '{'; });
|
||||
|
||||
// Get all the tasks.
|
||||
Filter filter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue