From 23eb91aa6e39d230083d5e258a00a0dd7e5f53f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Sat, 14 Sep 2019 12:42:34 +0200 Subject: [PATCH] Replace for-loop with while to improve readability. Note that I also moved the std::string out of the loop so that we do not need to allocate/deallocate the string several times. --- samples/taglist.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/taglist.cpp b/samples/taglist.cpp index bb87ee9a..e65f5262 100644 --- a/samples/taglist.cpp +++ b/samples/taglist.cpp @@ -46,14 +46,14 @@ int main(int argc, char* argv[]) if (item == "all" || item == "ALL" ) { const GroupInfo* groupList = ExifTags::groupList(); if (groupList) { + std::string line; while (groupList->tagList_) { std::ostringstream tags; ExifTags::taglist(tags,groupList->groupName_); - // https://en.cppreference.com/w/cpp/string/basic_string/getline std::istringstream input(tags.str()) ; - for (std::string line,comma(","); std::getline(input, line); ) { + while (std::getline(input, line)) { std::cout << groupList->groupName_ << "." - << (item == "all" ? line.substr(0,line.find(comma)) : line) + << (item == "all" ? line.substr(0,line.find(",")) : line) << std::endl; } groupList++;