diff options
author | Max Kellermann <max@musicpd.org> | 2020-11-04 16:29:13 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-11-04 16:37:53 +0100 |
commit | f2b9785a6706234d9c804a277f614a3f138eb171 (patch) | |
tree | 38ddd668e8bc896f9919df8f3f2b4dcabef7f1af /src | |
parent | eeaec99c596b1bc8b5dbadbb27b82bf50fd981c7 (diff) |
filter/chain: pass std::string_view to filter_chain_append()
Diffstat (limited to 'src')
-rw-r--r-- | src/filter/LoadChain.cxx | 10 | ||||
-rw-r--r-- | src/filter/plugins/ChainFilterPlugin.cxx | 6 | ||||
-rw-r--r-- | src/filter/plugins/ChainFilterPlugin.hxx | 3 |
3 files changed, 11 insertions, 8 deletions
diff --git a/src/filter/LoadChain.cxx b/src/filter/LoadChain.cxx index b24abc8f8..01c886fce 100644 --- a/src/filter/LoadChain.cxx +++ b/src/filter/LoadChain.cxx @@ -27,10 +27,13 @@ static void filter_chain_append_new(PreparedFilter &chain, FilterFactory &factory, - const char *template_name) + std::string_view template_name) { filter_chain_append(chain, template_name, - factory.MakeFilter(template_name)); + /* unfortunately, MakeFilter() wants a + null-terminated string, so we need to + copy it here */ + factory.MakeFilter(std::string(template_name).c_str())); } void @@ -42,7 +45,6 @@ filter_chain_parse(PreparedFilter &chain, if (i.empty()) continue; - const std::string name(i); - filter_chain_append_new(chain, factory, name.c_str()); + filter_chain_append_new(chain, factory, i); } } diff --git a/src/filter/plugins/ChainFilterPlugin.cxx b/src/filter/plugins/ChainFilterPlugin.cxx index 604a8344d..249130081 100644 --- a/src/filter/plugins/ChainFilterPlugin.cxx +++ b/src/filter/plugins/ChainFilterPlugin.cxx @@ -76,7 +76,7 @@ class PreparedChainFilter final : public PreparedFilter { const std::string name; std::unique_ptr<PreparedFilter> filter; - Child(const char *_name, + Child(std::string_view _name, std::unique_ptr<PreparedFilter> _filter) :name(_name), filter(std::move(_filter)) {} @@ -89,7 +89,7 @@ class PreparedChainFilter final : public PreparedFilter { std::list<Child> children; public: - void Append(const char *name, + void Append(std::string_view name, std::unique_ptr<PreparedFilter> filter) noexcept { children.emplace_back(name, std::move(filter)); } @@ -175,7 +175,7 @@ filter_chain_new() noexcept } void -filter_chain_append(PreparedFilter &_chain, const char *name, +filter_chain_append(PreparedFilter &_chain, std::string_view name, std::unique_ptr<PreparedFilter> filter) noexcept { auto &chain = (PreparedChainFilter &)_chain; diff --git a/src/filter/plugins/ChainFilterPlugin.hxx b/src/filter/plugins/ChainFilterPlugin.hxx index 06eb7c60a..8dd7e526c 100644 --- a/src/filter/plugins/ChainFilterPlugin.hxx +++ b/src/filter/plugins/ChainFilterPlugin.hxx @@ -28,6 +28,7 @@ #define MPD_FILTER_CHAIN_HXX #include <memory> +#include <string_view> class PreparedFilter; @@ -45,7 +46,7 @@ filter_chain_new() noexcept; * @param filter the filter to be appended to #chain */ void -filter_chain_append(PreparedFilter &chain, const char *name, +filter_chain_append(PreparedFilter &chain, std::string_view name, std::unique_ptr<PreparedFilter> filter) noexcept; #endif |