MCPcopy Create free account
hub / github.com/ashvardanian/less_slow.cpp / config_parse_sz

Function config_parse_sz

less_slow.cpp:4440–4455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4438#include <stringzilla/stringzilla.hpp>
4439
4440void 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
4457void parse_sz(bm::State &state, std::string_view config_text) {
4458 std::size_t pairs = 0, bytes = 0;

Callers 1

parse_szFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected