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
be5b726c
Commit
be5b726c
authored
Sep 12, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/StringView: remove Literal()
This is not necessary, because a strlen() on a literal gets optimized away by the compiler.
parent
34912189
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
22 deletions
+2
-22
Directory.cxx
src/db/plugins/upnp/Directory.cxx
+2
-2
StringView.hxx
src/util/StringView.hxx
+0
-20
No files found.
src/db/plugins/upnp/Directory.cxx
View file @
be5b726c
...
...
@@ -41,9 +41,9 @@ gcc_pure
static
UPnPDirObject
::
ItemClass
ParseItemClass
(
StringView
name
)
noexcept
{
if
(
name
.
Equals
Literal
(
"object.item.audioItem.musicTrack"
))
if
(
name
.
Equals
(
"object.item.audioItem.musicTrack"
))
return
UPnPDirObject
::
ItemClass
::
MUSIC
;
else
if
(
name
.
Equals
Literal
(
"object.item.playlistItem"
))
else
if
(
name
.
Equals
(
"object.item.playlistItem"
))
return
UPnPDirObject
::
ItemClass
::
PLAYLIST
;
else
return
UPnPDirObject
::
ItemClass
::
UNKNOWN
;
...
...
src/util/StringView.hxx
View file @
be5b726c
...
...
@@ -54,16 +54,6 @@ struct StringView : ConstBuffer<char> {
return
StringView
(
""
,
size_t
(
0
));
}
template
<
size_t
n
>
static
constexpr
StringView
Literal
(
const
char
(
&
_data
)[
n
])
noexcept
{
static_assert
(
n
>
0
,
""
);
return
{
_data
,
n
-
1
};
}
static
constexpr
StringView
Literal
()
noexcept
{
return
StringView
(
""
,
size_t
(
0
));
}
void
SetEmpty
()
noexcept
{
data
=
""
;
size
=
0
;
...
...
@@ -105,22 +95,12 @@ struct StringView : ConstBuffer<char> {
memcmp
(
data
,
other
.
data
,
size
)
==
0
;
}
template
<
size_t
n
>
bool
EqualsLiteral
(
const
char
(
&
other
)[
n
])
const
noexcept
{
return
Equals
(
Literal
(
other
));
}
gcc_pure
bool
EqualsIgnoreCase
(
StringView
other
)
const
noexcept
{
return
size
==
other
.
size
&&
strncasecmp
(
data
,
other
.
data
,
size
)
==
0
;
}
template
<
size_t
n
>
bool
EqualsLiteralIgnoreCase
(
const
char
(
&
other
)[
n
])
const
noexcept
{
return
EqualsIgnoreCase
(
Literal
(
other
));
}
/**
* Skip all whitespace at the beginning.
*/
...
...
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