diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx index 516a92f54..6aab20e5d 100644 --- a/src/db/DatabasePrint.cxx +++ b/src/db/DatabasePrint.cxx @@ -191,11 +191,11 @@ PrintSongUris(Response &r, Partition &partition, } static void -PrintUniqueTags(Response &r, ConstBuffer tag_types, +PrintUniqueTags(Response &r, std::span tag_types, const RecursiveMap &map) noexcept { const char *const name = tag_item_names[tag_types.front()]; - tag_types.pop_front(); + tag_types = tag_types.subspan(1); for (const auto &[key, tag] : map) { r.Fmt(FMT_STRING("{}: {}\n"), name, key); @@ -207,7 +207,7 @@ PrintUniqueTags(Response &r, ConstBuffer tag_types, void PrintUniqueTags(Response &r, Partition &partition, - ConstBuffer tag_types, + std::span tag_types, const SongFilter *filter) { const Database &db = partition.GetDatabaseOrThrow(); diff --git a/src/db/DatabasePrint.hxx b/src/db/DatabasePrint.hxx index a87a0c425..ad7176435 100644 --- a/src/db/DatabasePrint.hxx +++ b/src/db/DatabasePrint.hxx @@ -21,8 +21,8 @@ #define MPD_DB_PRINT_H #include +#include -template struct ConstBuffer; enum TagType : uint8_t; class SongFilter; struct DatabaseSelection; @@ -44,7 +44,7 @@ PrintSongUris(Response &r, Partition &partition, void PrintUniqueTags(Response &r, Partition &partition, - ConstBuffer tag_types, + std::span tag_types, const SongFilter *filter); #endif diff --git a/src/db/Interface.hxx b/src/db/Interface.hxx index c414611aa..1950e85e1 100644 --- a/src/db/Interface.hxx +++ b/src/db/Interface.hxx @@ -24,6 +24,7 @@ #include "tag/Type.h" #include +#include #include struct DatabasePlugin; @@ -31,7 +32,6 @@ struct DatabaseStats; struct DatabaseSelection; struct LightSong; template class RecursiveMap; -template struct ConstBuffer; class Database { const DatabasePlugin &plugin; @@ -111,7 +111,7 @@ public: * Throws on error. */ virtual RecursiveMap CollectUniqueTags(const DatabaseSelection &selection, - ConstBuffer tag_types) const = 0; + std::span tag_types) const = 0; /** * Throws on error. diff --git a/src/db/UniqueTags.cxx b/src/db/UniqueTags.cxx index cd1af6c2a..971068021 100644 --- a/src/db/UniqueTags.cxx +++ b/src/db/UniqueTags.cxx @@ -21,18 +21,18 @@ #include "Interface.hxx" #include "song/LightSong.hxx" #include "tag/VisitFallback.hxx" -#include "util/ConstBuffer.hxx" #include "util/RecursiveMap.hxx" static void CollectUniqueTags(RecursiveMap &result, const Tag &tag, - ConstBuffer tag_types) noexcept + std::span tag_types) noexcept { if (tag_types.empty()) return; - const auto tag_type = tag_types.shift(); + const auto tag_type = tag_types.front(); + tag_types = tag_types.subspan(1); VisitTagWithFallbackOrEmpty(tag, tag_type, [&result, &tag, tag_types](const char *value){ CollectUniqueTags(result[value], tag, tag_types); @@ -41,7 +41,7 @@ CollectUniqueTags(RecursiveMap &result, RecursiveMap CollectUniqueTags(const Database &db, const DatabaseSelection &selection, - ConstBuffer tag_types) + std::span tag_types) { RecursiveMap result; diff --git a/src/db/UniqueTags.hxx b/src/db/UniqueTags.hxx index de6dc00a7..53a41f086 100644 --- a/src/db/UniqueTags.hxx +++ b/src/db/UniqueTags.hxx @@ -22,18 +22,18 @@ #include "tag/Type.h" +#include #include class Database; struct DatabaseSelection; template class RecursiveMap; -template struct ConstBuffer; /** * Walk the database and collect unique tag values. */ RecursiveMap CollectUniqueTags(const Database &db, const DatabaseSelection &selection, - ConstBuffer tag_types); + std::span tag_types); #endif diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 981fe362e..e3a668ee4 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -37,7 +37,6 @@ #include "tag/Builder.hxx" #include "tag/Tag.hxx" #include "tag/ParseName.hxx" -#include "util/ConstBuffer.hxx" #include "util/RecursiveMap.hxx" #include "util/ScopeExit.hxx" #include "util/RuntimeError.hxx" @@ -136,7 +135,7 @@ public: VisitPlaylist visit_playlist) const override; RecursiveMap CollectUniqueTags(const DatabaseSelection &selection, - ConstBuffer tag_types) const override; + std::span tag_types) const override; DatabaseStats GetStats(const DatabaseSelection &selection) const override; @@ -440,13 +439,13 @@ SendGroup(mpd_connection *connection, TagType group) } static bool -SendGroup(mpd_connection *connection, ConstBuffer group) +SendGroup(mpd_connection *connection, std::span group) { while (!group.empty()) { if (!SendGroup(connection, group.back())) return false; - group.pop_back(); + group = group.first(group.size() - 1); } return true; @@ -1010,7 +1009,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection, RecursiveMap ProxyDatabase::CollectUniqueTags(const DatabaseSelection &selection, - ConstBuffer tag_types) const + std::span tag_types) const try { // TODO: eliminate the const_cast const_cast(this)->EnsureConnected(); @@ -1019,8 +1018,7 @@ try { if (tag_type2 == MPD_TAG_COUNT) throw std::runtime_error("Unsupported tag"); - auto group = tag_types; - group.pop_back(); + const auto group = tag_types.first(tag_types.size() - 1); if (!mpd_search_db_tags(connection, tag_type2) || !SendConstraints(connection, selection, selection.window) || diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index b99687def..874e54000 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -41,7 +41,6 @@ #include "fs/FileSystem.hxx" #include "util/CharUtil.hxx" #include "util/Domain.hxx" -#include "util/ConstBuffer.hxx" #include "util/RecursiveMap.hxx" #include "Log.hxx" @@ -334,7 +333,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, RecursiveMap SimpleDatabase::CollectUniqueTags(const DatabaseSelection &selection, - ConstBuffer tag_types) const + std::span tag_types) const { return ::CollectUniqueTags(*this, selection, tag_types); } diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.hxx b/src/db/plugins/simple/SimpleDatabasePlugin.hxx index 6b51c8015..8fd29c88f 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.hxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.hxx @@ -126,7 +126,7 @@ public: VisitPlaylist visit_playlist) const override; RecursiveMap CollectUniqueTags(const DatabaseSelection &selection, - ConstBuffer tag_types) const override; + std::span tag_types) const override; DatabaseStats GetStats(const DatabaseSelection &selection) const override; diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index a7a8fc548..675c85625 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -36,7 +36,6 @@ #include "db/Stats.hxx" #include "tag/Table.hxx" #include "fs/Traits.hxx" -#include "util/ConstBuffer.hxx" #include "util/RecursiveMap.hxx" #include "util/SplitString.hxx" #include "config/Block.hxx" @@ -101,7 +100,7 @@ public: VisitPlaylist visit_playlist) const override; [[nodiscard]] RecursiveMap CollectUniqueTags(const DatabaseSelection &selection, - ConstBuffer tag_types) const override; + std::span tag_types) const override; [[nodiscard]] DatabaseStats GetStats(const DatabaseSelection &selection) const override; @@ -629,7 +628,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, RecursiveMap UpnpDatabase::CollectUniqueTags(const DatabaseSelection &selection, - ConstBuffer tag_types) const + std::span tag_types) const { return ::CollectUniqueTags(*this, selection, tag_types); }