mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-21 01:47:51 +00:00
Update playlist file parsing, reduce allocs (#1157)
* Update playlist file parsing, reduce allocs * Cleanup, move impl to cpp
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user