Commit e2d2bb87 authored by Max Kellermann's avatar Max Kellermann

storage/Composite: use IterableSplitString()

parent a98d627c
......@@ -20,6 +20,7 @@
#include "CompositeStorage.hxx"
#include "FileInfo.hxx"
#include "fs/AllocatedPath.hxx"
#include "util/IterableSplitString.hxx"
#include "util/StringCompare.hxx"
#include <set>
......@@ -95,8 +96,11 @@ const CompositeStorage::Directory *
CompositeStorage::Directory::Find(std::string_view uri) const noexcept
{
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);
if (i == directory->children.end())
return nullptr;
......@@ -111,8 +115,11 @@ CompositeStorage::Directory &
CompositeStorage::Directory::Make(std::string_view uri)
{
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),
Directory());
directory = &i.first->second;
......
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