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
da155f88
Commit
da155f88
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/StringCompare: use [[gnu::]] attributes
parent
4026ef63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
26 deletions
+24
-26
StringCompare.hxx
src/util/StringCompare.hxx
+13
-14
WStringCompare.hxx
src/util/WStringCompare.hxx
+11
-12
No files found.
src/util/StringCompare.hxx
View file @
da155f88
/*
* 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
...
...
@@ -32,7 +32,6 @@
#include "StringView.hxx"
#include "StringAPI.hxx"
#include "Compiler.h"
#ifdef _UNICODE
#include "WStringCompare.hxx"
...
...
@@ -40,14 +39,14 @@
#include <string_view>
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
bool
StringIsEmpty
(
const
char
*
string
)
noexcept
{
return
*
string
==
0
;
}
gcc_pure
[[
gnu
::
pure
]]
static
inline
bool
StringIsEqual
(
std
::
string_view
a
,
std
::
string_view
b
)
noexcept
{
...
...
@@ -55,7 +54,7 @@ StringIsEqual(std::string_view a, std::string_view b) noexcept
StringIsEqual
(
a
.
data
(),
b
.
data
(),
b
.
size
());
}
gcc_pure
[[
gnu
::
pure
]]
static
inline
bool
StringIsEqualIgnoreCase
(
std
::
string_view
a
,
std
::
string_view
b
)
noexcept
{
...
...
@@ -63,18 +62,18 @@ StringIsEqualIgnoreCase(std::string_view a, std::string_view b) noexcept
StringIsEqualIgnoreCase
(
a
.
data
(),
b
.
data
(),
b
.
size
());
}
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
bool
StringStartsWith
(
const
char
*
haystack
,
StringView
needle
)
noexcept
{
return
StringIsEqual
(
haystack
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
bool
StringEndsWith
(
const
char
*
haystack
,
const
char
*
needle
)
noexcept
;
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
bool
StringEndsWithIgnoreCase
(
const
char
*
haystack
,
const
char
*
needle
)
noexcept
;
...
...
@@ -83,7 +82,7 @@ StringEndsWithIgnoreCase(const char *haystack, const char *needle) noexcept;
* does not begin with the specified prefix, this function returns
* nullptr.
*/
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
const
char
*
StringAfterPrefix
(
const
char
*
haystack
,
StringView
needle
)
noexcept
{
...
...
@@ -92,14 +91,14 @@ StringAfterPrefix(const char *haystack, StringView needle) noexcept
:
nullptr
;
}
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
bool
StringStartsWithIgnoreCase
(
const
char
*
haystack
,
StringView
needle
)
noexcept
{
return
StringIsEqualIgnoreCase
(
haystack
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
[[
gnu
::
pure
]]
static
inline
bool
StringStartsWithIgnoreCase
(
StringView
haystack
,
StringView
needle
)
noexcept
{
...
...
@@ -113,7 +112,7 @@ StringStartsWithIgnoreCase(StringView haystack, StringView needle) noexcept
* nullptr.
* This function is case-independent.
*/
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
const
char
*
StringAfterPrefixIgnoreCase
(
const
char
*
haystack
,
StringView
needle
)
noexcept
{
...
...
@@ -122,7 +121,7 @@ StringAfterPrefixIgnoreCase(const char *haystack, StringView needle) noexcept
:
nullptr
;
}
gcc_pure
[[
gnu
::
pure
]]
static
inline
StringView
StringAfterPrefixIgnoreCase
(
StringView
haystack
,
StringView
needle
)
noexcept
...
...
@@ -136,7 +135,7 @@ StringAfterPrefixIgnoreCase(StringView haystack,
* Check if the given string ends with the specified suffix. If yes,
* returns the position of the suffix, and nullptr otherwise.
*/
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
const
char
*
FindStringSuffix
(
const
char
*
p
,
const
char
*
suffix
)
noexcept
;
...
...
src/util/WStringCompare.hxx
View file @
da155f88
/*
* 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
...
...
@@ -32,20 +32,19 @@
#include "WStringView.hxx"
#include "WStringAPI.hxx"
#include "Compiler.h"
#include <string_view>
#include <wchar.h>
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
bool
StringIsEmpty
(
const
wchar_t
*
string
)
noexcept
{
return
*
string
==
0
;
}
gcc_pure
[[
gnu
::
pure
]]
static
inline
bool
StringIsEqual
(
std
::
wstring_view
a
,
std
::
wstring_view
b
)
noexcept
{
...
...
@@ -53,7 +52,7 @@ StringIsEqual(std::wstring_view a, std::wstring_view b) noexcept
StringIsEqual
(
a
.
data
(),
b
.
data
(),
b
.
size
());
}
gcc_pure
[[
gnu
::
pure
]]
static
inline
bool
StringIsEqualIgnoreCase
(
std
::
wstring_view
a
,
std
::
wstring_view
b
)
noexcept
{
...
...
@@ -61,18 +60,18 @@ StringIsEqualIgnoreCase(std::wstring_view a, std::wstring_view b) noexcept
StringIsEqualIgnoreCase
(
a
.
data
(),
b
.
data
(),
b
.
size
());
}
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
bool
StringStartsWith
(
const
wchar_t
*
haystack
,
WStringView
needle
)
noexcept
{
return
StringIsEqual
(
haystack
,
needle
.
data
,
needle
.
size
);
}
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
bool
StringEndsWith
(
const
wchar_t
*
haystack
,
const
wchar_t
*
needle
)
noexcept
;
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
bool
StringEndsWithIgnoreCase
(
const
wchar_t
*
haystack
,
const
wchar_t
*
needle
)
noexcept
;
...
...
@@ -82,7 +81,7 @@ StringEndsWithIgnoreCase(const wchar_t *haystack,
* does not begin with the specified prefix, this function returns
* nullptr.
*/
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
const
wchar_t
*
StringAfterPrefix
(
const
wchar_t
*
haystack
,
WStringView
needle
)
noexcept
{
...
...
@@ -91,7 +90,7 @@ StringAfterPrefix(const wchar_t *haystack, WStringView needle) noexcept
:
nullptr
;
}
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
bool
StringStartsWithIgnoreCase
(
const
wchar_t
*
haystack
,
WStringView
needle
)
noexcept
...
...
@@ -105,7 +104,7 @@ StringStartsWithIgnoreCase(const wchar_t *haystack,
* nullptr.
* This function is case-independent.
*/
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
static
inline
const
wchar_t
*
StringAfterPrefixIgnoreCase
(
const
wchar_t
*
haystack
,
WStringView
needle
)
noexcept
{
...
...
@@ -118,7 +117,7 @@ StringAfterPrefixIgnoreCase(const wchar_t *haystack, WStringView needle) noexcep
* Check if the given string ends with the specified suffix. If yes,
* returns the position of the suffix, and nullptr otherwise.
*/
gcc_pure
gcc_nonnull_all
[[
gnu
::
pure
]]
[[
gnu
::
nonnull
]]
const
wchar_t
*
FindStringSuffix
(
const
wchar_t
*
p
,
const
wchar_t
*
suffix
)
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