Update playlist file parsing, reduce allocs (#1157)

* Update playlist file parsing, reduce allocs
* Cleanup, move impl to cpp
This commit is contained in:
Kyle Reed 2023-06-15 13:15:26 -07:00 committed by GitHub
parent 34fefd1cad
commit d29826e6f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 233 additions and 94 deletions

View file

@ -131,25 +131,6 @@ using FileLineReader = BufferLineReader<File>;
* a vector of string_views. NB: the lifetime of the
* string to split must be maintained while the views
* are used or they will dangle. */
std::vector<std::string_view> split_string(std::string_view str, char c) {
std::vector<std::string_view> cols;
size_t start = 0;
while (start < str.length()) {
auto it = str.find(c, start);
if (it == str.npos)
break;
// TODO: allow empty?
cols.emplace_back(&str[start], it - start);
start = it + 1;
}
if (start <= str.length() && !str.empty())
cols.emplace_back(&str[start], str.length() - start);
return cols;
}
std::vector<std::string_view> split_string(std::string_view str, char c);
#endif