db/simple/Directory: use std::string_view instead of StringView
This commit is contained in:
@@ -32,13 +32,15 @@
|
|||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "util/DeleteDisposer.hxx"
|
#include "util/DeleteDisposer.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/StringView.hxx"
|
#include "util/StringSplit.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
using std::string_view_literals::operator""sv;
|
||||||
|
|
||||||
Directory::Directory(std::string &&_path_utf8, Directory *_parent) noexcept
|
Directory::Directory(std::string &&_path_utf8, Directory *_parent) noexcept
|
||||||
:parent(_parent),
|
:parent(_parent),
|
||||||
path(std::move(_path_utf8))
|
path(std::move(_path_utf8))
|
||||||
@@ -110,11 +112,9 @@ Directory::FindChild(std::string_view name) const noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
Song *
|
Song *
|
||||||
Directory::LookupTargetSong(std::string_view _target) noexcept
|
Directory::LookupTargetSong(std::string_view target) noexcept
|
||||||
{
|
{
|
||||||
StringView target{_target};
|
if (SkipPrefix(target, "../"sv)) {
|
||||||
|
|
||||||
if (target.SkipPrefix("../")) {
|
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@@ -151,11 +151,11 @@ Directory::LookupDirectory(std::string_view _uri) noexcept
|
|||||||
if (isRootDirectory(_uri))
|
if (isRootDirectory(_uri))
|
||||||
return { this, _uri, {} };
|
return { this, _uri, {} };
|
||||||
|
|
||||||
StringView uri(_uri);
|
auto uri = _uri;
|
||||||
|
|
||||||
Directory *d = this;
|
Directory *d = this;
|
||||||
do {
|
do {
|
||||||
auto [name, rest] = uri.Split(PathTraitsUTF8::SEPARATOR);
|
auto [name, rest] = Split(uri, PathTraitsUTF8::SEPARATOR);
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -167,9 +167,9 @@ Directory::LookupDirectory(std::string_view _uri) noexcept
|
|||||||
d = tmp;
|
d = tmp;
|
||||||
|
|
||||||
uri = rest;
|
uri = rest;
|
||||||
} while (uri != nullptr);
|
} while (uri.data() != nullptr);
|
||||||
|
|
||||||
return { d, _uri.substr(0, uri.data - _uri.data()), uri };
|
return { d, _uri.substr(0, uri.data() - _uri.data()), uri };
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/StringStrip.hxx"
|
#include "util/StringStrip.hxx"
|
||||||
#include "util/StringView.hxx"
|
|
||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user