summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-10-22 10:41:39 +0200
committerMax Kellermann <max@musicpd.org>2018-10-22 10:46:26 +0200
commit21adc78713881793958cd7606f96b099a93e020e (patch)
tree063052ac9d8939283f65b90a367b4d895f8ede61 /src
parent0340b01392a750a086b19abfdc47672308e0a2da (diff)
SongFilter: use ApplyTagFallback()
Diffstat (limited to 'src')
-rw-r--r--src/SongFilter.cxx26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx
index 2e0d6751a..faf5deb2a 100644
--- a/src/SongFilter.cxx
+++ b/src/SongFilter.cxx
@@ -22,6 +22,7 @@
#include "db/LightSong.hxx"
#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
+#include "tag/Fallback.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx"
#include "util/StringCompare.hxx"
@@ -118,14 +119,23 @@ SongFilter::Item::Match(const Tag &_tag) const noexcept
if (value.empty())
return true;
- if (tag == TAG_ALBUM_ARTIST && visited_types[TAG_ARTIST]) {
- /* if we're looking for "album artist", but
- only "artist" exists, use that */
- for (const auto &item : _tag)
- if (item.type == TAG_ARTIST &&
- StringMatch(item.value))
- return true;
- }
+ bool result = false;
+ if (ApplyTagFallback(TagType(tag),
+ [&](TagType tag2) {
+ if (!visited_types[tag2])
+ return false;
+
+ for (const auto &item : _tag) {
+ if (item.type == tag2 &&
+ StringMatch(item.value)) {
+ result = true;
+ break;
+ }
+ }
+
+ return true;
+ }))
+ return result;
}
return false;