From d5e0d49f86cc184a3f64d4ab8c59d82eace38c6c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 7 Nov 2018 23:57:42 +0100 Subject: [PATCH] song/{Tag,Uri}SongFilter: pass `StringFilter&&` to constructor --- src/song/Filter.cxx | 33 +++++++++++++++------------------ src/song/TagSongFilter.hxx | 8 ++------ src/song/UriSongFilter.hxx | 7 ++----- 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/song/Filter.cxx b/src/song/Filter.cxx index 0723f3c9f..f60da3cf4 100644 --- a/src/song/Filter.cxx +++ b/src/song/Filter.cxx @@ -93,9 +93,8 @@ SongFilter::SongFilter(TagType tag, const char *value, bool fold_case) { /* for compatibility with MPD 0.20 and older, "fold_case" also switches on "substring" */ - and_filter.AddItem(std::make_unique(tag, value, - fold_case, fold_case, - false)); + and_filter.AddItem(std::make_unique(tag, + StringFilter(value, fold_case, fold_case, false))); } SongFilter::~SongFilter() @@ -293,19 +292,17 @@ SongFilter::ParseExpression(const char *&s, bool fold_case) s = StripLeft(s + 1); + StringFilter string_filter(std::move(value), + fold_case, false, negated); + if (type == LOCATE_TAG_ANY_TYPE) type = TAG_NUM_OF_ITEM_TYPES; if (type == LOCATE_TAG_FILE_TYPE) - return std::make_unique(std::move(value), - fold_case, - false, - negated); + return std::make_unique(std::move(string_filter)); return std::make_unique(TagType(type), - std::move(value), - fold_case, false, - negated); + std::move(string_filter)); } } @@ -332,10 +329,10 @@ SongFilter::Parse(const char *tag_string, const char *value, bool fold_case) case LOCATE_TAG_FILE_TYPE: /* for compatibility with MPD 0.20 and older, "fold_case" also switches on "substring" */ - and_filter.AddItem(std::make_unique(value, - fold_case, - fold_case, - false)); + and_filter.AddItem(std::make_unique(StringFilter(value, + fold_case, + fold_case, + false))); break; default: @@ -345,10 +342,10 @@ SongFilter::Parse(const char *tag_string, const char *value, bool fold_case) /* for compatibility with MPD 0.20 and older, "fold_case" also switches on "substring" */ and_filter.AddItem(std::make_unique(TagType(tag), - value, - fold_case, - fold_case, - false)); + StringFilter(value, + fold_case, + fold_case, + false))); break; } } diff --git a/src/song/TagSongFilter.hxx b/src/song/TagSongFilter.hxx index b3e99a7f2..e60910934 100644 --- a/src/song/TagSongFilter.hxx +++ b/src/song/TagSongFilter.hxx @@ -37,12 +37,8 @@ class TagSongFilter final : public ISongFilter { StringFilter filter; public: - template - TagSongFilter(TagType _type, V &&_value, bool fold_case, bool substring, - bool negated) - :type(_type), - filter(std::forward(_value), fold_case, substring, - negated) {} + TagSongFilter(TagType _type, StringFilter &&_filter) noexcept + :type(_type), filter(std::move(_filter)) {} TagType GetTagType() const { return type; diff --git a/src/song/UriSongFilter.hxx b/src/song/UriSongFilter.hxx index 8ff979d66..60eba1a7e 100644 --- a/src/song/UriSongFilter.hxx +++ b/src/song/UriSongFilter.hxx @@ -27,11 +27,8 @@ class UriSongFilter final : public ISongFilter { StringFilter filter; public: - template - UriSongFilter(V &&_value, bool fold_case, bool substring, - bool negated) - :filter(std::forward(_value), fold_case, substring, - negated) {} + UriSongFilter(StringFilter &&_filter) noexcept + :filter(std::move(_filter)) {} const auto &GetValue() const noexcept { return filter.GetValue();