Commit b34fd905 authored by Max Kellermann's avatar Max Kellermann

SongFilter: simplify Parse() loop

Consume the ConstBuffer instead of iterating it. This will allow adding more complex parsers.
parent 821f7732
......@@ -216,11 +216,17 @@ SongFilter::Parse(const char *tag_string, const char *value, bool fold_case)
void
SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case)
{
if (args.size == 0 || args.size % 2 != 0)
if (args.empty())
throw std::runtime_error("Incorrect number of filter arguments");
for (unsigned i = 0; i < args.size; i += 2)
Parse(args[i], args[i + 1], fold_case);
do {
if (args.size < 2)
throw std::runtime_error("Incorrect number of filter arguments");
const char *tag = args.shift();
const char *value = args.shift();
Parse(tag, value, fold_case);
} while (!args.empty());
}
bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment