fs/StandardDirectory: use std::string_view instead of StringView

This commit is contained in:
Max Kellermann
2022-07-04 14:44:39 +02:00
parent 502e5f006a
commit 4964eda167
2 changed files with 6 additions and 9 deletions

@ -24,8 +24,8 @@
#include "StandardDirectory.hxx" #include "StandardDirectory.hxx"
#include "FileSystem.hxx" #include "FileSystem.hxx"
#include "XDG.hxx" #include "XDG.hxx"
#include "util/StringView.hxx"
#include "config.h" #include "config.h"
#include "util/StringSplit.hxx"
#include <array> #include <array>
@ -299,7 +299,7 @@ GetAppRuntimeDir() noexcept
#ifdef __linux__ #ifdef __linux__
/* systemd specific; see systemd.exec(5) */ /* systemd specific; see systemd.exec(5) */
if (const char *runtime_directory = getenv("RUNTIME_DIRECTORY")) if (const char *runtime_directory = getenv("RUNTIME_DIRECTORY"))
if (auto dir = StringView{runtime_directory}.Split(':').first; if (auto dir = Split(std::string_view{runtime_directory}, ':').first;
!dir.empty()) !dir.empty())
return AllocatedPath::FromFS(dir); return AllocatedPath::FromFS(dir);
#endif #endif

@ -19,7 +19,6 @@
#include "Traits.hxx" #include "Traits.hxx"
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
#include "util/StringView.hxx"
#include "util/UriExtract.hxx" #include "util/UriExtract.hxx"
#include <string.h> #include <string.h>
@ -138,17 +137,15 @@ RelativePathImpl(typename Traits::string_view base,
template<typename Traits> template<typename Traits>
typename Traits::string_view typename Traits::string_view
RelativePathImpl(typename Traits::string_view base, RelativePathImpl(typename Traits::string_view base,
typename Traits::string_view _other) noexcept typename Traits::string_view other) noexcept
{ {
BasicStringView<typename Traits::value_type> other(_other); if (!SkipPrefix(other, base))
if (!other.SkipPrefix(base))
/* mismatch */ /* mismatch */
return {}; return {};
if (!other.empty()) { if (!other.empty()) {
if (!Traits::IsSeparator(other.front())) { if (!Traits::IsSeparator(other.front())) {
if (!base.empty() && Traits::IsSeparator(other.data[-1])) if (!base.empty() && Traits::IsSeparator(other.data()[-1]))
/* "other" has no more slash, but the /* "other" has no more slash, but the
matching base ended with a slash: matching base ended with a slash:
enough to detect a match */ enough to detect a match */
@ -160,7 +157,7 @@ RelativePathImpl(typename Traits::string_view base,
/* skip remaining path separators */ /* skip remaining path separators */
while (!other.empty() && Traits::IsSeparator(other.front())) while (!other.empty() && Traits::IsSeparator(other.front()))
other.pop_front(); other.remove_prefix(1);
} }
return other; return other;