db/simple/Song: pass std::string_view to Load{File,FromArchive}()

This commit is contained in:
Max Kellermann 2023-04-30 08:18:57 +02:00
parent 99885c4cbc
commit 434bcb08ee
2 changed files with 6 additions and 6 deletions

View File

@ -34,10 +34,10 @@ Song::IsPluginAvailable() const noexcept
} }
SongPtr SongPtr
Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent) Song::LoadFile(Storage &storage, std::string_view path_utf8, Directory &parent)
{ {
assert(!uri_has_scheme(path_utf8)); assert(!uri_has_scheme(path_utf8));
assert(std::strchr(path_utf8, '\n') == nullptr); assert(path_utf8.find('\n') == path_utf8.npos);
auto song = std::make_unique<Song>(path_utf8, parent); auto song = std::make_unique<Song>(path_utf8, parent);
if (!song->UpdateFile(storage)) if (!song->UpdateFile(storage))
@ -89,11 +89,11 @@ Song::UpdateFile(Storage &storage)
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
SongPtr SongPtr
Song::LoadFromArchive(ArchiveFile &archive, const char *name_utf8, Song::LoadFromArchive(ArchiveFile &archive, std::string_view name_utf8,
Directory &parent) noexcept Directory &parent) noexcept
{ {
assert(!uri_has_scheme(name_utf8)); assert(!uri_has_scheme(name_utf8));
assert(std::strchr(name_utf8, '\n') == nullptr); assert(name_utf8.find('\n') == name_utf8.npos);
auto song = std::make_unique<Song>(name_utf8, parent); auto song = std::make_unique<Song>(name_utf8, parent);
if (!song->UpdateFileInArchive(archive)) if (!song->UpdateFileInArchive(archive))

View File

@ -105,7 +105,7 @@ struct Song : IntrusiveListHook<> {
* @return the song on success, nullptr if the file was not * @return the song on success, nullptr if the file was not
* recognized * recognized
*/ */
static SongPtr LoadFile(Storage &storage, const char *name_utf8, static SongPtr LoadFile(Storage &storage, std::string_view name_utf8,
Directory &parent); Directory &parent);
/** /**
@ -117,7 +117,7 @@ struct Song : IntrusiveListHook<> {
#ifdef ENABLE_ARCHIVE #ifdef ENABLE_ARCHIVE
static SongPtr LoadFromArchive(ArchiveFile &archive, static SongPtr LoadFromArchive(ArchiveFile &archive,
const char *name_utf8, std::string_view name_utf8,
Directory &parent) noexcept; Directory &parent) noexcept;
bool UpdateFileInArchive(ArchiveFile &archive) noexcept; bool UpdateFileInArchive(ArchiveFile &archive) noexcept;
#endif #endif