File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,16 +183,15 @@ std::string replaceEscapeSequences(const std::string &source) {
183183}
184184
185185
186- std::vector<std::string> splitString (const std::string& str, char sep)
186+ std::vector<std::string> splitString (std::string_view str, char sep)
187187{
188188 std::vector<std::string> l;
189-
190- std::string::size_type pos1 = 0 ;
191- std::string::size_type pos2;
189+ std::string_view::size_type pos1 = 0 ;
190+ std::string_view::size_type pos2 = std::string_view::npos;
192191 while (true ) {
193192 pos2 = str.find (sep, pos1);
194- l.push_back (str.substr (pos1, pos2 - pos1));
195- if (pos2 == std::string ::npos)
193+ l.emplace_back (str.substr (pos1, pos2 - pos1));
194+ if (pos2 == std::string_view ::npos)
196195 break ;
197196 pos1 = pos2 + 1 ;
198197 }
Original file line number Diff line number Diff line change 3535#include < type_traits>
3636#include < utility>
3737#include < vector>
38+ #include < string_view>
3839
3940struct SelectMapKeys {
4041 template <class Pair >
@@ -428,7 +429,7 @@ static inline T* empty_if_null(T* p)
428429 * @param sep The separator
429430 * @return The list of separate strings (including empty ones). The whole input string if no separator found.
430431 */
431- CPPCHECKLIB std::vector<std::string> splitString (const std::string& str, char sep);
432+ CPPCHECKLIB std::vector<std::string> splitString (std::string_view str, char sep);
432433
433434namespace utils {
434435 /* *
You can’t perform that action at this time.
0 commit comments