db/Song, SongUpdate: remove unnecessary c_str() calls

Just case implicitly to std::string_view, which is both simpler and
safer.
This commit is contained in:
Max Kellermann 2024-05-07 21:13:23 +02:00
parent 56bb1dddd7
commit 164b5b0cf3
3 changed files with 5 additions and 5 deletions

View File

@ -63,10 +63,10 @@ Song::UpdateFile(Storage &storage)
auto new_audio_format = AudioFormat::Undefined(); auto new_audio_format = AudioFormat::Undefined();
try { try {
const auto path_fs = storage.MapFS(relative_uri.c_str()); const auto path_fs = storage.MapFS(relative_uri);
if (path_fs.IsNull()) { if (path_fs.IsNull()) {
const auto absolute_uri = const auto absolute_uri =
storage.MapUTF8(relative_uri.c_str()); storage.MapUTF8(relative_uri);
if (!tag_stream_scan(absolute_uri.c_str(), tag_builder, if (!tag_stream_scan(absolute_uri.c_str(), tag_builder,
&new_audio_format)) &new_audio_format))
return false; return false;

View File

@ -21,7 +21,7 @@ DatabaseDetachSong(const Storage *storage, const LightSong &song) noexcept
if (storage != nullptr) { if (storage != nullptr) {
if (!detached.HasRealURI()) { if (!detached.HasRealURI()) {
const auto uri = song.GetURI(); const auto uri = song.GetURI();
detached.SetRealURI(storage->MapUTF8(uri.c_str())); detached.SetRealURI(storage->MapUTF8(uri));
} else if (uri_is_relative_path(detached.GetRealURI())) { } else if (uri_is_relative_path(detached.GetRealURI())) {
/* if the "RealURI" is relative, translate it /* if the "RealURI" is relative, translate it
using the song's "URI" attribute, because using the song's "URI" attribute, because
@ -29,7 +29,7 @@ DatabaseDetachSong(const Storage *storage, const LightSong &song) noexcept
const auto real_uri = const auto real_uri =
uri_apply_relative(detached.GetRealURI(), uri_apply_relative(detached.GetRealURI(),
song.GetURI()); song.GetURI());
detached.SetRealURI(storage->MapUTF8(real_uri.c_str())); detached.SetRealURI(storage->MapUTF8(real_uri));
} }
} }

View File

@ -16,5 +16,5 @@ Storage::MapChildFS(std::string_view uri_utf8,
std::string_view child_utf8) const noexcept std::string_view child_utf8) const noexcept
{ {
const auto uri2 = PathTraitsUTF8::Build(uri_utf8, child_utf8); const auto uri2 = PathTraitsUTF8::Build(uri_utf8, child_utf8);
return MapFS(uri2.c_str()); return MapFS(uri2);
} }