diff --git a/include/utils/string.hpp b/include/utils/string.hpp index a278e04f..fcb58b91 100644 --- a/include/utils/string.hpp +++ b/include/utils/string.hpp @@ -28,7 +28,7 @@ namespace string_util { string ltrim(const string& haystack, char needle); string rtrim(const string& haystack, char needle); string trim(const string& haystack, char needle); - string join(vector strs, string delim); + string join(const vector& strs, const string& delim); vector& split_into(const string& s, char delim, vector& container); vector split(const string& s, char delim); size_t find_nth(const string& haystack, size_t pos, const string& needle, size_t nth); diff --git a/src/utils/string.cpp b/src/utils/string.cpp index 4fae58c0..0fe88f10 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -164,10 +164,10 @@ namespace string_util { /** * Join all strings in vector into a single string separated by delim */ - string join(vector strs, string delim) { + string join(const vector& strs, const string& delim) { string str; for (auto& s : strs) { - str.append((str.empty() ? "" : move(delim)) + s); + str += (str.empty() ? "" : delim) + s; } return str; }