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
6593b599
Commit
6593b599
authored
Apr 02, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple/Directory: pass std::string_view to several methods
parent
386235e2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
30 deletions
+29
-30
Directory.cxx
src/db/plugins/simple/Directory.cxx
+5
-7
Directory.hxx
src/db/plugins/simple/Directory.hxx
+7
-6
Archive.cxx
src/db/update/Archive.cxx
+4
-5
Container.cxx
src/db/update/Container.cxx
+1
-1
Editor.cxx
src/db/update/Editor.cxx
+1
-1
Editor.hxx
src/db/update/Editor.hxx
+1
-1
Playlist.cxx
src/db/update/Playlist.cxx
+2
-2
VirtualDirectory.cxx
src/db/update/VirtualDirectory.cxx
+2
-2
Walk.hxx
src/db/update/Walk.hxx
+6
-5
No files found.
src/db/plugins/simple/Directory.cxx
View file @
6593b599
...
...
@@ -83,11 +83,10 @@ Directory::GetName() const noexcept
}
Directory
*
Directory
::
CreateChild
(
const
char
*
name_utf8
)
noexcept
Directory
::
CreateChild
(
std
::
string_view
name_utf8
)
noexcept
{
assert
(
holding_db_lock
());
assert
(
name_utf8
!=
nullptr
);
assert
(
*
name_utf8
!=
0
);
assert
(
!
name_utf8
.
empty
());
std
::
string
path_utf8
=
IsRoot
()
?
std
::
string
(
name_utf8
)
...
...
@@ -99,12 +98,12 @@ Directory::CreateChild(const char *name_utf8) noexcept
}
const
Directory
*
Directory
::
FindChild
(
const
char
*
name
)
const
noexcept
Directory
::
FindChild
(
std
::
string_view
name
)
const
noexcept
{
assert
(
holding_db_lock
());
for
(
const
auto
&
child
:
children
)
if
(
strcmp
(
child
.
GetName
(),
name
)
==
0
)
if
(
name
.
compare
(
child
.
GetName
()
)
==
0
)
return
&
child
;
return
nullptr
;
...
...
@@ -194,10 +193,9 @@ Directory::RemoveSong(Song *song) noexcept
}
const
Song
*
Directory
::
FindSong
(
const
char
*
name_utf8
)
const
noexcept
Directory
::
FindSong
(
std
::
string_view
name_utf8
)
const
noexcept
{
assert
(
holding_db_lock
());
assert
(
name_utf8
!=
nullptr
);
for
(
auto
&
song
:
songs
)
{
assert
(
&
song
.
parent
==
this
);
...
...
src/db/plugins/simple/Directory.hxx
View file @
6593b599
...
...
@@ -30,6 +30,7 @@
#include <boost/intrusive/list.hpp>
#include <string>
#include <string_view>
/**
* Virtual directory that is really an archive file or a folder inside
...
...
@@ -146,16 +147,16 @@ public:
*
* @param name_utf8 the UTF-8 encoded name of the new sub directory
*/
Directory
*
CreateChild
(
const
char
*
name_utf8
)
noexcept
;
Directory
*
CreateChild
(
std
::
string_view
name_utf8
)
noexcept
;
/**
* Caller must lock the #db_mutex.
*/
gcc_pure
const
Directory
*
FindChild
(
const
char
*
name
)
const
noexcept
;
const
Directory
*
FindChild
(
std
::
string_view
name
)
const
noexcept
;
gcc_pure
Directory
*
FindChild
(
const
char
*
name
)
noexcept
{
Directory
*
FindChild
(
std
::
string_view
name
)
noexcept
{
const
Directory
*
cthis
=
this
;
return
const_cast
<
Directory
*>
(
cthis
->
FindChild
(
name
));
}
...
...
@@ -166,7 +167,7 @@ public:
*
* Caller must lock the #db_mutex.
*/
Directory
*
MakeChild
(
const
char
*
name_utf8
)
noexcept
{
Directory
*
MakeChild
(
std
::
string_view
name_utf8
)
noexcept
{
Directory
*
child
=
FindChild
(
name_utf8
);
if
(
child
==
nullptr
)
child
=
CreateChild
(
name_utf8
);
...
...
@@ -247,10 +248,10 @@ public:
* Caller must lock the #db_mutex.
*/
gcc_pure
const
Song
*
FindSong
(
const
char
*
name_utf8
)
const
noexcept
;
const
Song
*
FindSong
(
std
::
string_view
name_utf8
)
const
noexcept
;
gcc_pure
Song
*
FindSong
(
const
char
*
name_utf8
)
noexcept
{
Song
*
FindSong
(
std
::
string_view
name_utf8
)
noexcept
{
const
Directory
*
cthis
=
this
;
return
const_cast
<
Song
*>
(
cthis
->
FindSong
(
name_utf8
));
}
...
...
src/db/update/Archive.cxx
View file @
6593b599
...
...
@@ -38,14 +38,14 @@
#include <string.h>
static
Directory
*
LockMakeChild
(
Directory
&
directory
,
const
char
*
name
)
noexcept
LockMakeChild
(
Directory
&
directory
,
std
::
string_view
name
)
noexcept
{
const
ScopeDatabaseLock
protect
;
return
directory
.
MakeChild
(
name
);
}
static
Song
*
LockFindSong
(
Directory
&
directory
,
const
char
*
name
)
noexcept
LockFindSong
(
Directory
&
directory
,
std
::
string_view
name
)
noexcept
{
const
ScopeDatabaseLock
protect
;
return
directory
.
FindSong
(
name
);
...
...
@@ -57,10 +57,9 @@ UpdateWalk::UpdateArchiveTree(ArchiveFile &archive, Directory &directory,
{
const
char
*
tmp
=
strchr
(
name
,
'/'
);
if
(
tmp
)
{
const
std
::
string
child_name
(
name
,
tmp
);
const
std
::
string
_view
child_name
(
name
,
tmp
-
name
);
//add dir is not there already
Directory
*
subdir
=
LockMakeChild
(
directory
,
child_name
.
c_str
());
Directory
*
subdir
=
LockMakeChild
(
directory
,
child_name
);
subdir
->
device
=
DEVICE_INARCHIVE
;
//create directories first
...
...
src/db/update/Container.cxx
View file @
6593b599
...
...
@@ -32,7 +32,7 @@
bool
UpdateWalk
::
UpdateContainerFile
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
std
::
string_view
name
,
const
char
*
suffix
,
const
StorageFileInfo
&
info
)
noexcept
{
const
DecoderPlugin
*
_plugin
=
decoder_plugins_find
([
suffix
](
const
DecoderPlugin
&
plugin
){
...
...
src/db/update/Editor.cxx
View file @
6593b599
...
...
@@ -88,7 +88,7 @@ DatabaseEditor::LockDeleteDirectory(Directory *directory)
}
bool
DatabaseEditor
::
DeleteNameIn
(
Directory
&
parent
,
const
char
*
name
)
DatabaseEditor
::
DeleteNameIn
(
Directory
&
parent
,
std
::
string_view
name
)
{
const
ScopeDatabaseLock
protect
;
...
...
src/db/update/Editor.hxx
View file @
6593b599
...
...
@@ -59,7 +59,7 @@ public:
*
* @return true if the database was modified
*/
bool
DeleteNameIn
(
Directory
&
parent
,
const
char
*
name
);
bool
DeleteNameIn
(
Directory
&
parent
,
std
::
string_view
name
);
private
:
void
ClearDirectory
(
Directory
&
directory
);
...
...
src/db/update/Playlist.cxx
View file @
6593b599
...
...
@@ -34,7 +34,7 @@
#include "Log.hxx"
void
UpdateWalk
::
UpdatePlaylistFile
(
Directory
&
parent
,
const
char
*
name
,
UpdateWalk
::
UpdatePlaylistFile
(
Directory
&
parent
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
const
PlaylistPlugin
&
plugin
)
noexcept
{
...
...
@@ -88,7 +88,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, const char *name,
bool
UpdateWalk
::
UpdatePlaylistFile
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
std
::
string_view
name
,
const
char
*
suffix
,
const
StorageFileInfo
&
info
)
noexcept
{
const
auto
*
const
plugin
=
FindPlaylistPluginBySuffix
(
suffix
);
...
...
src/db/update/VirtualDirectory.cxx
View file @
6593b599
...
...
@@ -23,7 +23,7 @@
#include "storage/FileInfo.hxx"
Directory
*
UpdateWalk
::
MakeVirtualDirectoryIfModified
(
Directory
&
parent
,
const
char
*
name
,
UpdateWalk
::
MakeVirtualDirectoryIfModified
(
Directory
&
parent
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
unsigned
virtual_device
)
noexcept
{
...
...
@@ -53,7 +53,7 @@ UpdateWalk::MakeVirtualDirectoryIfModified(Directory &parent, const char *name,
Directory
*
UpdateWalk
::
LockMakeVirtualDirectoryIfModified
(
Directory
&
parent
,
const
char
*
name
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
unsigned
virtual_device
)
noexcept
{
...
...
src/db/update/Walk.hxx
View file @
6593b599
...
...
@@ -26,6 +26,7 @@
#include "config.h"
#include <atomic>
#include <string_view>
struct
StorageFileInfo
;
struct
Directory
;
...
...
@@ -93,7 +94,7 @@ private:
const
StorageFileInfo
&
info
)
noexcept
;
bool
UpdateContainerFile
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
std
::
string_view
name
,
const
char
*
suffix
,
const
StorageFileInfo
&
info
)
noexcept
;
...
...
@@ -119,12 +120,12 @@ private:
}
#endif
void
UpdatePlaylistFile
(
Directory
&
parent
,
const
char
*
name
,
void
UpdatePlaylistFile
(
Directory
&
parent
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
const
PlaylistPlugin
&
plugin
)
noexcept
;
bool
UpdatePlaylistFile
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
std
::
string_view
name
,
const
char
*
suffix
,
const
StorageFileInfo
&
info
)
noexcept
;
bool
UpdateRegularFile
(
Directory
&
directory
,
...
...
@@ -151,12 +152,12 @@ private:
* specifying the kind of virtual directory
*/
Directory
*
MakeVirtualDirectoryIfModified
(
Directory
&
parent
,
const
char
*
name
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
unsigned
virtual_device
)
noexcept
;
Directory
*
LockMakeVirtualDirectoryIfModified
(
Directory
&
parent
,
const
char
*
name
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
unsigned
virtual_device
)
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