From d3f28a1d7f6ccd3274b648001a55d8a327657beb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 19 Oct 2013 16:34:11 +0200 Subject: [PATCH] FilterConfig: use std::find instead of g_strsplit_set() --- src/FilterConfig.cxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/FilterConfig.cxx b/src/FilterConfig.cxx index 0b0509af3..a52cf44b7 100644 --- a/src/FilterConfig.cxx +++ b/src/FilterConfig.cxx @@ -29,7 +29,7 @@ #include "ConfigError.hxx" #include "util/Error.hxx" -#include +#include #include @@ -89,22 +89,22 @@ filter_chain_append_new(Filter &chain, const char *template_name, Error &error) bool filter_chain_parse(Filter &chain, const char *spec, Error &error) { - // Split on comma - gchar** tokens = g_strsplit_set(spec, ",", 255); + const char *const end = spec + strlen(spec); - // Add each name to the filter chain by instantiating an actual filter - char **template_names = tokens; - while (*template_names != NULL) { - // Squeeze whitespace - g_strstrip(*template_names); + while (true) { + const char *comma = std::find(spec, end, ','); + if (comma > spec) { + const std::string name(spec, comma); + if (!filter_chain_append_new(chain, name.c_str(), + error)) + return false; + } - if (!filter_chain_append_new(chain, *template_names, error)) - return false; + if (comma == end) + break; - ++template_names; + spec = comma + 1; } - g_strfreev(tokens); - return true; }