db/simple/Mount: pass std::string_view to WalkMount()

This commit is contained in:
Max Kellermann 2020-04-02 19:34:22 +02:00
parent ddfd92e547
commit 386235e2d2
2 changed files with 11 additions and 9 deletions

View File

@ -31,7 +31,7 @@ struct PrefixedLightDirectory : LightDirectory {
std::string buffer; std::string buffer;
PrefixedLightDirectory(const LightDirectory &directory, PrefixedLightDirectory(const LightDirectory &directory,
const char *base) std::string_view base)
:LightDirectory(directory), :LightDirectory(directory),
buffer(IsRoot() buffer(IsRoot()
? std::string(base) ? std::string(base)
@ -41,21 +41,21 @@ struct PrefixedLightDirectory : LightDirectory {
}; };
static void static void
PrefixVisitDirectory(const char *base, const VisitDirectory &visit_directory, PrefixVisitDirectory(std::string_view base, const VisitDirectory &visit_directory,
const LightDirectory &directory) const LightDirectory &directory)
{ {
visit_directory(PrefixedLightDirectory(directory, base)); visit_directory(PrefixedLightDirectory(directory, base));
} }
static void static void
PrefixVisitSong(const char *base, const VisitSong &visit_song, PrefixVisitSong(std::string_view base, const VisitSong &visit_song,
const LightSong &song) const LightSong &song)
{ {
visit_song(PrefixedLightSong(song, base)); visit_song(PrefixedLightSong(song, base));
} }
static void static void
PrefixVisitPlaylist(const char *base, const VisitPlaylist &visit_playlist, PrefixVisitPlaylist(std::string_view base, const VisitPlaylist &visit_playlist,
const PlaylistInfo &playlist, const PlaylistInfo &playlist,
const LightDirectory &directory) const LightDirectory &directory)
{ {
@ -64,8 +64,8 @@ PrefixVisitPlaylist(const char *base, const VisitPlaylist &visit_playlist,
} }
void void
WalkMount(const char *base, const Database &db, WalkMount(std::string_view base, const Database &db,
const char *uri, std::string_view uri,
const DatabaseSelection &old_selection, const DatabaseSelection &old_selection,
const VisitDirectory &visit_directory, const VisitSong &visit_song, const VisitDirectory &visit_directory, const VisitSong &visit_song,
const VisitPlaylist &visit_playlist) const VisitPlaylist &visit_playlist)
@ -92,7 +92,7 @@ WalkMount(const char *base, const Database &db,
SongFilter prefix_filter; SongFilter prefix_filter;
if (base != nullptr && selection.filter != nullptr) { if (base.data() != nullptr && selection.filter != nullptr) {
/* if the SongFilter contains a LOCATE_TAG_BASE_TYPE /* if the SongFilter contains a LOCATE_TAG_BASE_TYPE
item, copy the SongFilter and drop the mount point item, copy the SongFilter and drop the mount point
from the filter, because the mounted database from the filter, because the mounted database

View File

@ -22,12 +22,14 @@
#include "db/Visitor.hxx" #include "db/Visitor.hxx"
#include <string_view>
class Database; class Database;
struct DatabaseSelection; struct DatabaseSelection;
void void
WalkMount(const char *base, const Database &db, WalkMount(std::string_view base, const Database &db,
const char *uri, std::string_view uri,
const DatabaseSelection &old_selection, const DatabaseSelection &old_selection,
const VisitDirectory &visit_directory, const VisitSong &visit_song, const VisitDirectory &visit_directory, const VisitSong &visit_song,
const VisitPlaylist &visit_playlist); const VisitPlaylist &visit_playlist);