util: don't modify the input string in tokenize_string()

This saves one full copy of the input string and avoids moving memory
around at O(n^2) in the erase() call in each loop iteration.
This commit is contained in:
Max Kellermann 2020-01-31 11:31:10 +01:00
parent 70b45d1aba
commit e068ad8a53
2 changed files with 7 additions and 6 deletions

View file

@ -145,7 +145,7 @@ inline std::string get_escaped_string(const std::string& str, bool escape_all)
return get_escaped_string(str.data(), str.length(), escape_all);
}
std::vector<std::string>* tokenize_string(std::string input,
std::vector<std::string>* tokenize_string(const std::string &input,
const std::string& delim,
std::vector<std::string>* rval = 0, int limit = 0);