SongFilter: remove DetachedSong overloads
All DetachedSong instances should be converted to LightSong first, which is a very cheap operation.
This commit is contained in:
parent
96017f58a5
commit
78a65cf281
@ -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"
|
||||
@ -157,21 +157,6 @@ SongFilter::Item::MatchNN(const Tag &_tag) const noexcept
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
@ -380,16 +365,6 @@ SongFilter::Parse(ConstBuffer<const char *> args, bool fold_case)
|
||||
} while (!args.empty());
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
@ -45,7 +45,6 @@ template<typename T> struct ConstBuffer;
|
||||
struct Tag;
|
||||
struct TagItem;
|
||||
struct LightSong;
|
||||
class DetachedSong;
|
||||
|
||||
class SongFilter {
|
||||
public:
|
||||
@ -110,17 +109,13 @@ public:
|
||||
gcc_pure
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
@ -153,9 +148,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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user