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
672278e5
Commit
672278e5
authored
Jul 22, 2021
by
Max Kellermann
Committed by
Max Kellermann
Aug 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/StringView: use [[gnu::]] attributes
parent
da155f88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
StringView.hxx
src/util/StringView.hxx
+14
-14
WStringView.hxx
src/util/WStringView.hxx
+1
-1
No files found.
src/util/StringView.hxx
View file @
672278e5
/*
* Copyright 2013-202
0
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2013-202
1
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -103,12 +103,12 @@ struct BasicStringView : ConstBuffer<T> {
return
{
start
,
size_t
(
data
+
size
-
start
)};
}
gcc_pure
[[
gnu
::
pure
]]
pointer
Find
(
value_type
ch
)
const
noexcept
{
return
StringFind
(
data
,
ch
,
this
->
size
);
}
gcc_pure
[[
gnu
::
pure
]]
pointer
FindLast
(
value_type
ch
)
const
noexcept
{
return
StringFindLast
(
data
,
ch
,
size
);
}
...
...
@@ -118,7 +118,7 @@ struct BasicStringView : ConstBuffer<T> {
* character. If the character is not found, then the first
* value is the whole string and the second value is nullptr.
*/
gcc_pure
[[
gnu
::
pure
]]
std
::
pair
<
BasicStringView
<
T
>
,
BasicStringView
<
T
>>
Split
(
value_type
ch
)
const
noexcept
{
const
auto
separator
=
Find
(
ch
);
if
(
separator
==
nullptr
)
...
...
@@ -132,7 +132,7 @@ struct BasicStringView : ConstBuffer<T> {
* character. If the character is not found, then the first
* value is the whole string and the second value is nullptr.
*/
gcc_pure
[[
gnu
::
pure
]]
std
::
pair
<
BasicStringView
<
T
>
,
BasicStringView
<
T
>>
SplitLast
(
value_type
ch
)
const
noexcept
{
const
auto
separator
=
FindLast
(
ch
);
if
(
separator
==
nullptr
)
...
...
@@ -141,30 +141,30 @@ struct BasicStringView : ConstBuffer<T> {
return
{{
begin
(),
separator
},
{
separator
+
1
,
end
()}};
}
gcc_pure
[[
gnu
::
pure
]]
bool
StartsWith
(
BasicStringView
<
T
>
needle
)
const
noexcept
{
return
this
->
size
>=
needle
.
size
&&
StringIsEqual
(
data
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
[[
gnu
::
pure
]]
bool
EndsWith
(
BasicStringView
<
T
>
needle
)
const
noexcept
{
return
this
->
size
>=
needle
.
size
&&
StringIsEqual
(
data
+
this
->
size
-
needle
.
size
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
[[
gnu
::
pure
]]
bool
StartsWith
(
value_type
ch
)
const
noexcept
{
return
!
empty
()
&&
front
()
==
ch
;
}
gcc_pure
[[
gnu
::
pure
]]
bool
EndsWith
(
value_type
ch
)
const
noexcept
{
return
!
empty
()
&&
back
()
==
ch
;
}
gcc_pure
[[
gnu
::
pure
]]
int
Compare
(
BasicStringView
<
T
>
other
)
const
noexcept
{
if
(
size
<
other
.
size
)
{
int
result
=
StringCompare
(
data
,
other
.
data
,
size
);
...
...
@@ -181,26 +181,26 @@ struct BasicStringView : ConstBuffer<T> {
return
StringCompare
(
data
,
other
.
data
,
size
);
}
gcc_pure
[[
gnu
::
pure
]]
bool
Equals
(
BasicStringView
<
T
>
other
)
const
noexcept
{
return
this
->
size
==
other
.
size
&&
StringIsEqual
(
data
,
other
.
data
,
this
->
size
);
}
gcc_pure
[[
gnu
::
pure
]]
bool
StartsWithIgnoreCase
(
BasicStringView
<
T
>
needle
)
const
noexcept
{
return
this
->
size
>=
needle
.
size
&&
StringIsEqualIgnoreCase
(
data
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
[[
gnu
::
pure
]]
bool
EndsWithIgnoreCase
(
BasicStringView
<
T
>
needle
)
const
noexcept
{
return
this
->
size
>=
needle
.
size
&&
StringIsEqualIgnoreCase
(
data
+
this
->
size
-
needle
.
size
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
[[
gnu
::
pure
]]
bool
EqualsIgnoreCase
(
BasicStringView
<
T
>
other
)
const
noexcept
{
return
this
->
size
==
other
.
size
&&
StringIsEqualIgnoreCase
(
data
,
other
.
data
,
this
->
size
);
...
...
src/util/WStringView.hxx
View file @
672278e5
/*
* Copyright
(C) 2013-2017
Max Kellermann <max.kellermann@gmail.com>
* Copyright
2013-2021
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
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