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

@ -22,6 +22,7 @@
*/
#include "ui_looking_glass_app.hpp"
#include "convert.hpp"
#include "file_reader.hpp"
#include "string_format.hpp"
@ -534,11 +535,15 @@ void GlassView::load_Presets() {
if (cols.size() != 3)
continue;
// TODO: add some conversion helpers that take string_view.
presets_db.emplace_back(preset_entry{
std::stoi(std::string{cols[0]}),
std::stoi(std::string{cols[1]}),
trimr(std::string{cols[2]})});
preset_entry entry{};
parse_int(cols[0], entry.min);
parse_int(cols[1], entry.max);
entry.label = trimr(cols[2]);
if (entry.min == 0 || entry.max == 0 || entry.min >= entry.max)
continue; // Invalid line.
presets_db.emplace_back(std::move(entry));
}
}