diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2016-10-29 11:35:33 +0200 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2016-10-29 11:35:33 +0200 |
commit | 8dd4a066ca0312ff03595b96a75abc8c6123f576 (patch) | |
tree | cf6aac6897f1ae4244b4b309627fc28902da2df9 /zen/string_tools.h | |
parent | 8.4 (diff) | |
download | FreeFileSync-8dd4a066ca0312ff03595b96a75abc8c6123f576.tar.gz FreeFileSync-8dd4a066ca0312ff03595b96a75abc8c6123f576.tar.bz2 FreeFileSync-8dd4a066ca0312ff03595b96a75abc8c6123f576.zip |
8.5
Diffstat (limited to 'zen/string_tools.h')
-rw-r--r-- | zen/string_tools.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/zen/string_tools.h b/zen/string_tools.h index 3bda665f..525227d6 100644 --- a/zen/string_tools.h +++ b/zen/string_tools.h @@ -229,12 +229,11 @@ template <class S, class T> inline std::vector<S> split(const S& str, const T& delimiter) { static_assert(IsSameType<typename GetCharType<S>::Type, typename GetCharType<T>::Type>::value, ""); - std::vector<S> output; const size_t delimLen = strLength(delimiter); if (delimLen == 0) - output.push_back(str); + return { str }; else { const auto* const delimFirst = strBegin(delimiter); @@ -242,6 +241,8 @@ std::vector<S> split(const S& str, const T& delimiter) const auto* blockStart = strBegin(str); const auto* const strLast = blockStart + strLength(str); + + std::vector<S> output; for (;;) { @@ -249,12 +250,11 @@ std::vector<S> split(const S& str, const T& delimiter) delimFirst, delimLast); output.emplace_back(blockStart, blockEnd - blockStart); - if (blockEnd == strLast) - break; + if (blockEnd == strLast) //clients expect: if delimiter not found, return str + return output; blockStart = blockEnd + delimLen; } } - return output; } |