From f0923231d0bf47f60a639bf57dd86010b7978067 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Thu, 2 Apr 2020 20:10:36 +0200
Subject: [PATCH] storage/Interface: pass std::string_view to MapChildFS()

---
 src/db/update/Archive.cxx        | 4 ++--
 src/db/update/UpdateIO.cxx       | 2 +-
 src/db/update/UpdateIO.hxx       | 2 +-
 src/db/update/Walk.cxx           | 4 ++--
 src/db/update/Walk.hxx           | 8 ++++----
 src/storage/StorageInterface.cxx | 4 ++--
 src/storage/StorageInterface.hxx | 5 +++--
 7 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/db/update/Archive.cxx b/src/db/update/Archive.cxx
index 74f754d64..9baab7b63 100644
--- a/src/db/update/Archive.cxx
+++ b/src/db/update/Archive.cxx
@@ -122,7 +122,7 @@ class UpdateArchiveVisitor final : public ArchiveVisitor {
  * @param plugin the archive plugin which fits this archive type
  */
 void
-UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
+UpdateWalk::UpdateArchiveFile(Directory &parent, std::string_view name,
 			      const StorageFileInfo &info,
 			      const ArchivePlugin &plugin) noexcept
 {
@@ -157,7 +157,7 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
 
 bool
 UpdateWalk::UpdateArchiveFile(Directory &directory,
-			      const char *name, const char *suffix,
+			      std::string_view name, const char *suffix,
 			      const StorageFileInfo &info) noexcept
 {
 	const ArchivePlugin *plugin = archive_plugin_from_suffix(suffix);
diff --git a/src/db/update/UpdateIO.cxx b/src/db/update/UpdateIO.cxx
index 32788b5b5..0292a3411 100644
--- a/src/db/update/UpdateIO.cxx
+++ b/src/db/update/UpdateIO.cxx
@@ -85,7 +85,7 @@ try {
 
 bool
 directory_child_access(Storage &storage, const Directory &directory,
-		       const char *name, int mode) noexcept
+		       std::string_view name, int mode) noexcept
 {
 #ifdef _WIN32
 	/* CheckAccess() is useless on WIN32 */
diff --git a/src/db/update/UpdateIO.hxx b/src/db/update/UpdateIO.hxx
index d58dbb647..455abaca0 100644
--- a/src/db/update/UpdateIO.hxx
+++ b/src/db/update/UpdateIO.hxx
@@ -58,6 +58,6 @@ directory_child_is_regular(Storage &storage, const Directory &directory,
 gcc_pure
 bool
 directory_child_access(Storage &storage, const Directory &directory,
-		       const char *name, int mode) noexcept;
+		       std::string_view name, int mode) noexcept;
 
 #endif
diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx
index 2cefc2743..ff55be1bc 100644
--- a/src/db/update/Walk.cxx
+++ b/src/db/update/Walk.cxx
@@ -229,7 +229,7 @@ skip_path(const char *name_utf8) noexcept
 gcc_pure
 bool
 UpdateWalk::SkipSymlink(const Directory *directory,
-			const char *utf8_name) const noexcept
+			std::string_view utf8_name) const noexcept
 {
 #ifndef _WIN32
 	const auto path_fs = storage.MapChildFS(directory->GetPath(),
@@ -369,7 +369,7 @@ UpdateWalk::UpdateDirectory(Directory &directory,
 inline Directory *
 UpdateWalk::DirectoryMakeChildChecked(Directory &parent,
 				      const char *uri_utf8,
-				      const char *name_utf8) noexcept
+				      std::string_view name_utf8) noexcept
 {
 	Directory *directory;
 	{
diff --git a/src/db/update/Walk.hxx b/src/db/update/Walk.hxx
index 447568aae..99253ca47 100644
--- a/src/db/update/Walk.hxx
+++ b/src/db/update/Walk.hxx
@@ -78,7 +78,7 @@ public:
 private:
 	gcc_pure
 	bool SkipSymlink(const Directory *directory,
-			 const char *utf8_name) const noexcept;
+			 std::string_view utf8_name) const noexcept;
 
 	void RemoveExcludedFromDirectory(Directory &directory,
 					 const ExcludeList &exclude_list) noexcept;
@@ -103,10 +103,10 @@ private:
 			       const char *name) noexcept;
 
 	bool UpdateArchiveFile(Directory &directory,
-			       const char *name, const char *suffix,
+			       std::string_view name, const char *suffix,
 			       const StorageFileInfo &info) noexcept;
 
-	void UpdateArchiveFile(Directory &directory, const char *name,
+	void UpdateArchiveFile(Directory &directory, std::string_view name,
 			       const StorageFileInfo &info,
 			       const ArchivePlugin &plugin) noexcept;
 
@@ -163,7 +163,7 @@ private:
 
 	Directory *DirectoryMakeChildChecked(Directory &parent,
 					     const char *uri_utf8,
-					     const char *name_utf8) noexcept;
+					     std::string_view name_utf8) noexcept;
 
 	Directory *DirectoryMakeUriParentChecked(Directory &root,
 						 const char *uri) noexcept;
diff --git a/src/storage/StorageInterface.cxx b/src/storage/StorageInterface.cxx
index 821c18251..183b46655 100644
--- a/src/storage/StorageInterface.cxx
+++ b/src/storage/StorageInterface.cxx
@@ -28,8 +28,8 @@ Storage::MapFS([[maybe_unused]] const char *uri_utf8) const noexcept
 }
 
 AllocatedPath
-Storage::MapChildFS(const char *uri_utf8,
-		    const char *child_utf8) const noexcept
+Storage::MapChildFS(std::string_view uri_utf8,
+		    std::string_view child_utf8) const noexcept
 {
 	const auto uri2 = PathTraitsUTF8::Build(uri_utf8, child_utf8);
 	return MapFS(uri2.c_str());
diff --git a/src/storage/StorageInterface.hxx b/src/storage/StorageInterface.hxx
index 71a7358e4..e1a0626a6 100644
--- a/src/storage/StorageInterface.hxx
+++ b/src/storage/StorageInterface.hxx
@@ -24,6 +24,7 @@
 
 #include <memory>
 #include <string>
+#include <string_view>
 
 struct StorageFileInfo;
 class AllocatedPath;
@@ -73,8 +74,8 @@ public:
 	virtual AllocatedPath MapFS(const char *uri_utf8) const noexcept;
 
 	gcc_pure
-	AllocatedPath MapChildFS(const char *uri_utf8,
-				 const char *child_utf8) const noexcept;
+	AllocatedPath MapChildFS(std::string_view uri_utf8,
+				 std::string_view child_utf8) const noexcept;
 
 	/**
 	 * Check if the given URI points inside this storage.  If yes,