| 4438 | #include <stringzilla/stringzilla.hpp> |
| 4439 | |
| 4440 | void config_parse_sz(std::string_view config_text, std::vector<std::pair<std::string, std::string>> &settings) { |
| 4441 | namespace sz = ashvardanian::stringzilla; |
| 4442 | |
| 4443 | auto newlines = sz::char_set("\r\n"); |
| 4444 | auto whitespaces = sz::whitespaces_set(); |
| 4445 | |
| 4446 | for (sz::string_view line : sz::string_view {config_text}.split(newlines)) { |
| 4447 | line = line.strip(whitespaces); |
| 4448 | if (line.empty() || line.front() == '#') continue; // Skip empty lines or comments |
| 4449 | auto [key, delimiter, value] = line.partition(':'); |
| 4450 | key = key.strip(whitespaces); |
| 4451 | value = value.strip(whitespaces); |
| 4452 | if (key.empty() || value.empty()) continue; // Skip invalid lines |
| 4453 | settings.emplace_back(key, value); |
| 4454 | } |
| 4455 | } |
| 4456 | |
| 4457 | void parse_sz(bm::State &state, std::string_view config_text) { |
| 4458 | std::size_t pairs = 0, bytes = 0; |