From d5fd3094848da0b7d34187c4e8ff5e05f3323a35 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 2 Apr 2020 19:48:22 +0200 Subject: [PATCH] db/update/IO: pass std::string_view to directory_child_is_regular() --- src/db/update/UpdateIO.cxx | 4 ++-- src/db/update/UpdateIO.hxx | 4 +++- src/db/update/Walk.cxx | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/db/update/UpdateIO.cxx b/src/db/update/UpdateIO.cxx index c122406c2..32788b5b5 100644 --- a/src/db/update/UpdateIO.cxx +++ b/src/db/update/UpdateIO.cxx @@ -66,7 +66,7 @@ DirectoryExists(Storage &storage, const Directory &directory) noexcept static StorageFileInfo GetDirectoryChildInfo(Storage &storage, const Directory &directory, - const char *name_utf8) + std::string_view name_utf8) { const auto uri_utf8 = PathTraitsUTF8::Build(directory.GetPath(), name_utf8); @@ -75,7 +75,7 @@ GetDirectoryChildInfo(Storage &storage, const Directory &directory, bool directory_child_is_regular(Storage &storage, const Directory &directory, - const char *name_utf8) noexcept + std::string_view name_utf8) noexcept try { return GetDirectoryChildInfo(storage, directory, name_utf8) .IsRegular(); diff --git a/src/db/update/UpdateIO.hxx b/src/db/update/UpdateIO.hxx index 0adde7e25..d58dbb647 100644 --- a/src/db/update/UpdateIO.hxx +++ b/src/db/update/UpdateIO.hxx @@ -22,6 +22,8 @@ #include "util/Compiler.h" +#include + struct Directory; struct StorageFileInfo; class Storage; @@ -48,7 +50,7 @@ DirectoryExists(Storage &storage, const Directory &directory) noexcept; gcc_pure bool directory_child_is_regular(Storage &storage, const Directory &directory, - const char *name_utf8) noexcept; + std::string_view name_utf8) noexcept; /** * Checks if the given permissions on the mapped file are given. diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index bdc207825..2cefc2743 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -103,7 +103,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept directory.ForEachSongSafe([&](Song &song){ if (!directory_child_is_regular(storage, directory, - song.filename.c_str())) { + song.filename)) { editor.LockDeleteSong(directory, &song); modified = true; @@ -113,8 +113,7 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept for (auto i = directory.playlists.begin(), end = directory.playlists.end(); i != end;) { - if (!directory_child_is_regular(storage, directory, - i->name.c_str())) { + if (!directory_child_is_regular(storage, directory, i->name)) { const ScopeDatabaseLock protect; i = directory.playlists.erase(i); } else