Commit 78a65cf2 authored by Max Kellermann's avatar Max Kellermann

SongFilter: remove DetachedSong overloads

All DetachedSong instances should be converted to LightSong first, which is a very cheap operation.
parent 96017f58
......@@ -20,8 +20,8 @@
#include "config.h"
#include "SongFilter.hxx"
#include "db/LightSong.hxx"
#include "DetachedSong.hxx"
#include "tag/ParseName.hxx"
#include "tag/Tag.hxx"
#include "util/CharUtil.hxx"
#include "util/ChronoUtil.hxx"
#include "util/ConstBuffer.hxx"
......@@ -158,21 +158,6 @@ SongFilter::Item::MatchNN(const Tag &_tag) const noexcept
}
bool
SongFilter::Item::MatchNN(const DetachedSong &song) const noexcept
{
if (tag == LOCATE_TAG_BASE_TYPE)
return uri_is_child_or_same(value.c_str(), song.GetURI());
if (tag == LOCATE_TAG_MODIFIED_SINCE)
return song.GetLastModified() >= time;
if (tag == LOCATE_TAG_FILE_TYPE)
return StringMatchNN(song.GetURI());
return MatchNN(song.GetTag());
}
bool
SongFilter::Item::MatchNN(const LightSong &song) const noexcept
{
if (tag == LOCATE_TAG_BASE_TYPE) {
......@@ -381,16 +366,6 @@ SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case)
}
bool
SongFilter::Match(const DetachedSong &song) const noexcept
{
for (const auto &i : items)
if (!i.Match(song))
return false;
return true;
}
bool
SongFilter::Match(const LightSong &song) const noexcept
{
for (const auto &i : items)
......
......@@ -45,7 +45,6 @@ template<typename T> struct ConstBuffer;
struct Tag;
struct TagItem;
struct LightSong;
class DetachedSong;
class SongFilter {
public:
......@@ -111,16 +110,12 @@ public:
bool MatchNN(const Tag &tag) const noexcept;
gcc_pure
bool MatchNN(const DetachedSong &song) const noexcept;
gcc_pure
bool MatchNN(const LightSong &song) const noexcept;
public:
template<typename T>
gcc_pure
bool Match(const T &t) const noexcept {
return MatchNN(t) != IsNegated();
bool Match(const LightSong &song) const noexcept {
return MatchNN(song) != IsNegated();
}
};
......@@ -154,9 +149,6 @@ public:
void Parse(ConstBuffer<const char *> args, bool fold_case=false);
gcc_pure
bool Match(const DetachedSong &song) const noexcept;
gcc_pure
bool Match(const LightSong &song) const noexcept;
const std::list<Item> &GetItems() const noexcept {
......
......@@ -22,6 +22,8 @@
#include "Queue.hxx"
#include "SongFilter.hxx"
#include "SongPrint.hxx"
#include "DetachedSong.hxx"
#include "db/LightSong.hxx"
#include "client/Response.hxx"
/**
......@@ -111,7 +113,7 @@ queue_find(Response &r, const Queue &queue,
const SongFilter &filter)
{
for (unsigned i = 0; i < queue.GetLength(); i++) {
const DetachedSong &song = queue.Get(i);
const LightSong song{queue.Get(i)};
if (filter.Match(song))
queue_print_song_info(r, queue, i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment