storage/Composite: use IterableSplitString()
This commit is contained in:
parent
a98d627c0b
commit
e2d2bb8755
|
@ -20,6 +20,7 @@
|
||||||
#include "CompositeStorage.hxx"
|
#include "CompositeStorage.hxx"
|
||||||
#include "FileInfo.hxx"
|
#include "FileInfo.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
|
#include "util/IterableSplitString.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -95,8 +96,11 @@ const CompositeStorage::Directory *
|
||||||
CompositeStorage::Directory::Find(std::string_view uri) const noexcept
|
CompositeStorage::Directory::Find(std::string_view uri) const noexcept
|
||||||
{
|
{
|
||||||
const Directory *directory = this;
|
const Directory *directory = this;
|
||||||
while (!uri.empty()) {
|
|
||||||
const auto name = NextSegment(uri);
|
for (std::string_view name : IterableSplitString(uri, '/')) {
|
||||||
|
if (name.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
auto i = directory->children.find(name);
|
auto i = directory->children.find(name);
|
||||||
if (i == directory->children.end())
|
if (i == directory->children.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -111,8 +115,11 @@ CompositeStorage::Directory &
|
||||||
CompositeStorage::Directory::Make(std::string_view uri)
|
CompositeStorage::Directory::Make(std::string_view uri)
|
||||||
{
|
{
|
||||||
Directory *directory = this;
|
Directory *directory = this;
|
||||||
while (!uri.empty()) {
|
|
||||||
auto name = NextSegment(uri);
|
for (std::string_view name : IterableSplitString(uri, '/')) {
|
||||||
|
if (name.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
auto i = directory->children.emplace(std::move(name),
|
auto i = directory->children.emplace(std::move(name),
|
||||||
Directory());
|
Directory());
|
||||||
directory = &i.first->second;
|
directory = &i.first->second;
|
||||||
|
|
Loading…
Reference in New Issue