From 25b7f4281058c0868586223d7405195f973bd496 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 1 Nov 2015 13:50:45 -0500 Subject: [PATCH] CmdExport: Simplified looping with 'auto' --- src/commands/CmdExport.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/commands/CmdExport.cpp b/src/commands/CmdExport.cpp index 78682ffad..fb7ed8aac 100644 --- a/src/commands/CmdExport.cpp +++ b/src/commands/CmdExport.cpp @@ -79,18 +79,19 @@ int CmdExport::execute (std::string& output) output += "[\n"; int counter = 0; - for (auto task = filtered.begin (); task != filtered.end (); ++task) + for (auto& task : filtered) { - if (task != filtered.begin ()) - { - if (json_array) - output += ","; - output += "\n"; - } + if (counter) + { + if (json_array) + output += ","; + output += "\n"; + } - output += task->composeJSON (true); + output += task.composeJSON (true); - if (limit && ++counter >= limit) + ++counter; + if (limit && counter >= limit) break; }