Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3a83a6b5
Commit
3a83a6b5
authored
Apr 03, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/Composite: NextSegment() returns std::string_view
parent
bcf46452
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
CompositeStorage.cxx
src/storage/CompositeStorage.cxx
+6
-6
CompositeStorage.hxx
src/storage/CompositeStorage.hxx
+1
-1
No files found.
src/storage/CompositeStorage.cxx
View file @
3a83a6b5
...
...
@@ -82,17 +82,17 @@ CompositeDirectoryReader::GetInfo(bool follow)
return
StorageFileInfo
(
StorageFileInfo
::
Type
::
DIRECTORY
);
}
static
std
::
string
static
std
::
string
_view
NextSegment
(
const
char
*&
uri_r
)
{
const
char
*
uri
=
uri_r
;
const
char
*
slash
=
strchr
(
uri
,
'/'
);
if
(
slash
==
nullptr
)
{
uri_r
+=
strlen
(
uri
);
return
std
::
string
(
uri
)
;
return
uri
;
}
else
{
uri_r
=
slash
+
1
;
return
std
::
string
(
uri
,
slash
);
return
std
::
string
_view
(
uri
,
slash
-
uri
);
}
}
...
...
@@ -101,7 +101,7 @@ CompositeStorage::Directory::Find(const char *uri) const noexcept
{
const
Directory
*
directory
=
this
;
while
(
*
uri
!=
0
)
{
const
std
::
string
name
=
NextSegment
(
uri
);
const
auto
name
=
NextSegment
(
uri
);
auto
i
=
directory
->
children
.
find
(
name
);
if
(
i
==
directory
->
children
.
end
())
return
nullptr
;
...
...
@@ -142,7 +142,7 @@ CompositeStorage::Directory::Unmount(const char *uri) noexcept
if
(
StringIsEmpty
(
uri
))
return
Unmount
();
const
std
::
string
name
=
NextSegment
(
uri
);
const
auto
name
=
NextSegment
(
uri
);
auto
i
=
children
.
find
(
name
);
if
(
i
==
children
.
end
()
||
!
i
->
second
.
Unmount
(
uri
))
...
...
@@ -227,7 +227,7 @@ CompositeStorage::FindStorage(const char *uri) const noexcept
const
Directory
*
directory
=
&
root
;
while
(
*
uri
!=
0
)
{
const
std
::
string
name
=
NextSegment
(
uri
);
const
auto
name
=
NextSegment
(
uri
);
auto
i
=
directory
->
children
.
find
(
name
);
if
(
i
==
directory
->
children
.
end
())
...
...
src/storage/CompositeStorage.hxx
View file @
3a83a6b5
...
...
@@ -49,7 +49,7 @@ class CompositeStorage final : public Storage {
*/
std
::
unique_ptr
<
Storage
>
storage
;
std
::
map
<
std
::
string
,
Directory
>
children
;
std
::
map
<
std
::
string
,
Directory
,
std
::
less
<>
>
children
;
gcc_pure
bool
IsEmpty
()
const
noexcept
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment