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
6197b29a
Commit
6197b29a
authored
Apr 02, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/PlaylistInfo: pass std::string_view to CompareName
parent
02294a82
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
PlaylistInfo.hxx
src/db/PlaylistInfo.hxx
+5
-3
PlaylistVector.cxx
src/db/PlaylistVector.cxx
+2
-3
PlaylistVector.hxx
src/db/PlaylistVector.hxx
+3
-2
No files found.
src/db/PlaylistInfo.hxx
View file @
6197b29a
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "util/Compiler.h"
#include "util/Compiler.h"
#include <string>
#include <string>
#include <string_view>
#include <chrono>
#include <chrono>
/**
/**
...
@@ -42,14 +43,15 @@ struct PlaylistInfo {
...
@@ -42,14 +43,15 @@ struct PlaylistInfo {
std
::
chrono
::
system_clock
::
time_point
::
min
();
std
::
chrono
::
system_clock
::
time_point
::
min
();
class
CompareName
{
class
CompareName
{
const
char
*
const
name
;
const
std
::
string_view
name
;
public
:
public
:
constexpr
CompareName
(
const
char
*
_name
)
:
name
(
_name
)
{}
constexpr
CompareName
(
std
::
string_view
_name
)
noexcept
:
name
(
_name
)
{}
gcc_pure
gcc_pure
bool
operator
()(
const
PlaylistInfo
&
pi
)
const
noexcept
{
bool
operator
()(
const
PlaylistInfo
&
pi
)
const
noexcept
{
return
pi
.
name
.
compare
(
name
)
==
0
;
return
pi
.
name
==
name
;
}
}
};
};
...
...
src/db/PlaylistVector.cxx
View file @
6197b29a
...
@@ -24,10 +24,9 @@
...
@@ -24,10 +24,9 @@
#include <cassert>
#include <cassert>
PlaylistVector
::
iterator
PlaylistVector
::
iterator
PlaylistVector
::
find
(
const
char
*
name
)
noexcept
PlaylistVector
::
find
(
std
::
string_view
name
)
noexcept
{
{
assert
(
holding_db_lock
());
assert
(
holding_db_lock
());
assert
(
name
!=
nullptr
);
return
std
::
find_if
(
begin
(),
end
(),
return
std
::
find_if
(
begin
(),
end
(),
PlaylistInfo
::
CompareName
(
name
));
PlaylistInfo
::
CompareName
(
name
));
...
@@ -51,7 +50,7 @@ PlaylistVector::UpdateOrInsert(PlaylistInfo &&pi) noexcept
...
@@ -51,7 +50,7 @@ PlaylistVector::UpdateOrInsert(PlaylistInfo &&pi) noexcept
}
}
bool
bool
PlaylistVector
::
erase
(
const
char
*
name
)
noexcept
PlaylistVector
::
erase
(
std
::
string_view
name
)
noexcept
{
{
assert
(
holding_db_lock
());
assert
(
holding_db_lock
());
...
...
src/db/PlaylistVector.hxx
View file @
6197b29a
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "util/Compiler.h"
#include "util/Compiler.h"
#include <list>
#include <list>
#include <string_view>
class
PlaylistVector
:
protected
std
::
list
<
PlaylistInfo
>
{
class
PlaylistVector
:
protected
std
::
list
<
PlaylistInfo
>
{
protected
:
protected
:
...
@@ -31,7 +32,7 @@ protected:
...
@@ -31,7 +32,7 @@ protected:
* Caller must lock the #db_mutex.
* Caller must lock the #db_mutex.
*/
*/
gcc_pure
gcc_pure
iterator
find
(
const
char
*
name
)
noexcept
;
iterator
find
(
std
::
string_view
name
)
noexcept
;
public
:
public
:
using
std
::
list
<
PlaylistInfo
>::
empty
;
using
std
::
list
<
PlaylistInfo
>::
empty
;
...
@@ -50,7 +51,7 @@ public:
...
@@ -50,7 +51,7 @@ public:
/**
/**
* Caller must lock the #db_mutex.
* Caller must lock the #db_mutex.
*/
*/
bool
erase
(
const
char
*
name
)
noexcept
;
bool
erase
(
std
::
string_view
name
)
noexcept
;
};
};
#endif
/* SONGVEC_H */
#endif
/* SONGVEC_H */
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