From 95e4cfc5947fb5a324f6dad50cff8d71f928aba8 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Wed, 11 Jan 2017 14:05:41 +0100 Subject: Autogen: Generators: Simplify (and fix) JoinExts function --- Source/cmQtAutoGenerators.cxx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 73afdc1..f3fa047 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -99,20 +99,18 @@ static bool ListContains(const std::vector& list, static std::string JoinExts(const std::vector& lst) { - if (lst.empty()) { - return ""; - } - std::string result; - std::string separator = ","; - for (std::vector::const_iterator it = lst.begin(); - it != lst.end(); ++it) { - if (it != lst.begin()) { - result += separator; + if (!lst.empty()) { + const std::string separator = ","; + for (std::vector::const_iterator it = lst.begin(); + it != lst.end(); ++it) { + if (it != lst.begin()) { + result += separator; + } + result += '.'; + result += *it; } - result += '.' + (*it); } - result.erase(result.end() - 1); return result; } -- cgit v0.12