filter/LoadChain: use IterableSplitString()

This commit is contained in:
Max Kellermann 2020-11-04 16:32:54 +01:00
parent b0002e3b73
commit eeaec99c59

View File

@ -21,12 +21,10 @@
#include "Factory.hxx"
#include "Prepared.hxx"
#include "plugins/ChainFilterPlugin.hxx"
#include "util/IterableSplitString.hxx"
#include <algorithm>
#include <string>
#include <string.h>
static void
filter_chain_append_new(PreparedFilter &chain, FilterFactory &factory,
const char *template_name)
@ -40,18 +38,11 @@ filter_chain_parse(PreparedFilter &chain,
FilterFactory &factory,
const char *spec)
{
const char *const end = spec + strlen(spec);
for (const std::string_view i : IterableSplitString(spec, ',')) {
if (i.empty())
continue;
while (true) {
const char *comma = std::find(spec, end, ',');
if (comma > spec) {
const std::string name(spec, comma);
filter_chain_append_new(chain, factory, name.c_str());
}
if (comma == end)
break;
spec = comma + 1;
const std::string name(i);
filter_chain_append_new(chain, factory, name.c_str());
}
}