From 0506bf03525b84b0d8a7fa92e15ab8ad01523c3a Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 21 Dec 2014 07:30:30 +0800 Subject: [PATCH] Reapply fmt::merge change --- Utilities/StrFmt.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index ae150c4f79..c17d374fe5 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -137,14 +137,17 @@ std::vector fmt::split(const std::string& source, std::initializer_ std::string fmt::merge(std::vector source, const std::string& separator) { + if (!source.size()) + return ""; + std::string result; - for (auto &s : source) + for (int i = 0; i < source.size() - 1; ++i) { - result += s + separator; + result += source[i] + separator; } - return result; + return result + source[source.size() - 1]; } std::string fmt::merge(std::initializer_list> sources, const std::string& separator)