diff options
author | Max Kellermann <max@musicpd.org> | 2020-03-13 19:58:36 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-03-13 19:58:36 +0100 |
commit | cefc773992bcb87feb2874ea4b7a94ba8117ba44 (patch) | |
tree | e3946010bb5b06465f6100cf3e7b258c01ecff59 /src | |
parent | a885bdba4ce2c3a077bc5e6c9654793dbe70bf3c (diff) |
playlist/PlaylistSong: pass std::string_view
Diffstat (limited to 'src')
-rw-r--r-- | src/playlist/PlaylistSong.cxx | 8 | ||||
-rw-r--r-- | src/playlist/PlaylistSong.hxx | 4 | ||||
-rw-r--r-- | src/queue/QueueSave.cxx | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/playlist/PlaylistSong.cxx b/src/playlist/PlaylistSong.cxx index e97614b9a..fdd12bad9 100644 --- a/src/playlist/PlaylistSong.cxx +++ b/src/playlist/PlaylistSong.cxx @@ -65,15 +65,15 @@ try { } bool -playlist_check_translate_song(DetachedSong &song, const char *base_uri, +playlist_check_translate_song(DetachedSong &song, std::string_view base_uri, const SongLoader &loader) noexcept { - if (base_uri != nullptr && strcmp(base_uri, ".") == 0) + if (base_uri.compare(".") == 0) /* PathTraitsUTF8::GetParent() returns "." when there is no directory name in the given path; clear that now, because it would break the database lookup functions */ - base_uri = nullptr; + base_uri = {}; const char *uri = song.GetURI(); @@ -92,7 +92,7 @@ playlist_check_translate_song(DetachedSong &song, const char *base_uri, } #endif - if (base_uri != nullptr && !uri_has_scheme(uri) && + if (base_uri.data() != nullptr && !uri_has_scheme(uri) && !PathTraitsUTF8::IsAbsolute(uri)) song.SetURI(PathTraitsUTF8::Build(base_uri, uri)); diff --git a/src/playlist/PlaylistSong.hxx b/src/playlist/PlaylistSong.hxx index f733da725..8f077922b 100644 --- a/src/playlist/PlaylistSong.hxx +++ b/src/playlist/PlaylistSong.hxx @@ -20,6 +20,8 @@ #ifndef MPD_PLAYLIST_SONG_HXX #define MPD_PLAYLIST_SONG_HXX +#include <string_view> + class SongLoader; class DetachedSong; @@ -30,7 +32,7 @@ class DetachedSong; * @return true on success, false if the song should not be used */ bool -playlist_check_translate_song(DetachedSong &song, const char *base_uri, +playlist_check_translate_song(DetachedSong &song, std::string_view base_uri, const SongLoader &loader) noexcept; #endif diff --git a/src/queue/QueueSave.cxx b/src/queue/QueueSave.cxx index a16f0414e..4e1017d63 100644 --- a/src/queue/QueueSave.cxx +++ b/src/queue/QueueSave.cxx @@ -112,7 +112,7 @@ queue_load_song(TextFile &file, const SongLoader &loader, auto song = LoadQueueSong(file, line); - if (!playlist_check_translate_song(song, nullptr, loader)) + if (!playlist_check_translate_song(song, {}, loader)) return; queue.Append(std::move(song), priority); |