Commit 2429cc87 authored by Max Kellermann's avatar Max Kellermann

fs/Traits: convert first Relative() parameter to std::string_view

parent 3a83a6b5
......@@ -86,10 +86,9 @@ GetParentPathImpl(typename Traits::const_pointer p) noexcept
template<typename Traits>
typename Traits::const_pointer
RelativePathImpl(typename Traits::const_pointer base,
RelativePathImpl(typename Traits::string_view base,
typename Traits::const_pointer other) noexcept
{
assert(base != nullptr);
assert(other != nullptr);
other = StringAfterPrefix(other, base);
......@@ -99,7 +98,7 @@ RelativePathImpl(typename Traits::const_pointer base,
if (*other != 0) {
if (!Traits::IsSeparator(*other)) {
if (*base != 0 && Traits::IsSeparator(other[-1]))
if (!base.empty() && Traits::IsSeparator(other[-1]))
/* "other" has no more slash, but the
matching base ended with a slash:
enough to detect a match */
......@@ -137,7 +136,7 @@ PathTraitsFS::GetParent(PathTraitsFS::const_pointer p) noexcept
}
PathTraitsFS::const_pointer
PathTraitsFS::Relative(const_pointer base, const_pointer other) noexcept
PathTraitsFS::Relative(string_view base, const_pointer other) noexcept
{
return RelativePathImpl<PathTraitsFS>(base, other);
}
......@@ -175,8 +174,7 @@ PathTraitsUTF8::GetParent(const_pointer p) noexcept
}
PathTraitsUTF8::const_pointer
PathTraitsUTF8::Relative(const_pointer base,
const_pointer other) noexcept
PathTraitsUTF8::Relative(string_view base, const_pointer other) noexcept
{
return RelativePathImpl<PathTraitsUTF8>(base, other);
}
......@@ -147,8 +147,7 @@ struct PathTraitsFS {
* nullptr on mismatch.
*/
gcc_pure gcc_nonnull_all
static const_pointer Relative(const_pointer base,
const_pointer other) noexcept;
static const_pointer Relative(string_view base, const_pointer other) noexcept;
/**
* Constructs the path from the given components.
......@@ -256,8 +255,7 @@ struct PathTraitsUTF8 {
* nullptr on mismatch.
*/
gcc_pure gcc_nonnull_all
static const_pointer Relative(const_pointer base,
const_pointer other) noexcept;
static const_pointer Relative(string_view base, const_pointer other) noexcept;
/**
* Constructs the path from the given components.
......
......@@ -81,7 +81,7 @@ CurlStorage::MapUTF8(const char *uri_utf8) const noexcept
const char *
CurlStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{
return PathTraitsUTF8::Relative(base.c_str(),
return PathTraitsUTF8::Relative(base,
CurlUnescape(uri_utf8).c_str());
}
......
......@@ -129,7 +129,7 @@ LocalStorage::MapFS(const char *uri_utf8) const noexcept
const char *
LocalStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{
return PathTraitsUTF8::Relative(base_utf8.c_str(), uri_utf8);
return PathTraitsUTF8::Relative(base_utf8, uri_utf8);
}
StorageFileInfo
......
......@@ -246,7 +246,7 @@ NfsStorage::MapUTF8(const char *uri_utf8) const noexcept
const char *
NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{
return PathTraitsUTF8::Relative(base.c_str(), uri_utf8);
return PathTraitsUTF8::Relative(base, uri_utf8);
}
static void
......
......@@ -87,7 +87,7 @@ SmbclientStorage::MapUTF8(const char *uri_utf8) const noexcept
const char *
SmbclientStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{
return PathTraitsUTF8::Relative(base.c_str(), uri_utf8);
return PathTraitsUTF8::Relative(base, uri_utf8);
}
static StorageFileInfo
......
......@@ -347,7 +347,7 @@ UdisksStorage::MapUTF8(const char *uri_utf8) const noexcept
const char *
UdisksStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
{
return PathTraitsUTF8::Relative(base_uri.c_str(), uri_utf8);
return PathTraitsUTF8::Relative(base_uri, uri_utf8);
}
static std::unique_ptr<Storage>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment