From 434bcb08eef7525bd0be36225eabb08a38df13e8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 30 Apr 2023 08:18:57 +0200 Subject: [PATCH] db/simple/Song: pass std::string_view to Load{File,FromArchive}() --- src/SongUpdate.cxx | 8 ++++---- src/db/plugins/simple/Song.hxx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index d1d612f11..4b7edac8b 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -34,10 +34,10 @@ Song::IsPluginAvailable() const noexcept } 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(std::strchr(path_utf8, '\n') == nullptr); + assert(path_utf8.find('\n') == path_utf8.npos); auto song = std::make_unique(path_utf8, parent); if (!song->UpdateFile(storage)) @@ -89,11 +89,11 @@ Song::UpdateFile(Storage &storage) #ifdef ENABLE_ARCHIVE SongPtr -Song::LoadFromArchive(ArchiveFile &archive, const char *name_utf8, +Song::LoadFromArchive(ArchiveFile &archive, std::string_view name_utf8, Directory &parent) noexcept { 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(name_utf8, parent); if (!song->UpdateFileInArchive(archive)) diff --git a/src/db/plugins/simple/Song.hxx b/src/db/plugins/simple/Song.hxx index b67d555ea..deb6a1ffd 100644 --- a/src/db/plugins/simple/Song.hxx +++ b/src/db/plugins/simple/Song.hxx @@ -105,7 +105,7 @@ struct Song : IntrusiveListHook<> { * @return the song on success, nullptr if the file was not * recognized */ - static SongPtr LoadFile(Storage &storage, const char *name_utf8, + static SongPtr LoadFile(Storage &storage, std::string_view name_utf8, Directory &parent); /** @@ -117,7 +117,7 @@ struct Song : IntrusiveListHook<> { #ifdef ENABLE_ARCHIVE static SongPtr LoadFromArchive(ArchiveFile &archive, - const char *name_utf8, + std::string_view name_utf8, Directory &parent) noexcept; bool UpdateFileInArchive(ArchiveFile &archive) noexcept; #endif