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
db6db517
Commit
db6db517
authored
Aug 07, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/CharUtil: add IsWhitespaceFast()
parent
981be795
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
6 deletions
+19
-6
LogBackend.cxx
src/LogBackend.cxx
+1
-1
ClientRead.cxx
src/client/ClientRead.cxx
+1
-1
TextInputStream.cxx
src/input/TextInputStream.cxx
+1
-1
CharUtil.hxx
src/util/CharUtil.hxx
+13
-0
Tokenizer.cxx
src/util/Tokenizer.cxx
+3
-3
No files found.
src/LogBackend.cxx
View file @
db6db517
...
...
@@ -120,7 +120,7 @@ chomp_length(const char *p)
{
size_t
length
=
strlen
(
p
);
while
(
length
>
0
&&
IsWhitespace
OrNull
(
p
[
length
-
1
]))
while
(
length
>
0
&&
IsWhitespace
Fast
(
p
[
length
-
1
]))
--
length
;
return
(
int
)
length
;
...
...
src/client/ClientRead.cxx
View file @
db6db517
...
...
@@ -39,7 +39,7 @@ Client::OnSocketInput(void *data, size_t length)
BufferedSocket
::
ConsumeInput
(
newline
+
1
-
p
);
/* skip whitespace at the end of the line */
while
(
newline
>
p
&&
IsWhitespace
OrNull
(
newline
[
-
1
]))
while
(
newline
>
p
&&
IsWhitespace
Fast
(
newline
[
-
1
]))
--
newline
;
/* terminate the string at the end of the line */
...
...
src/input/TextInputStream.cxx
View file @
db6db517
...
...
@@ -72,7 +72,7 @@ TextInputStream::ReadLine()
buffer
.
Consume
(
p
-
src
+
1
);
while
(
p
>
src
&&
IsWhitespace
OrNull
(
p
[
-
1
]))
while
(
p
>
src
&&
IsWhitespace
Fast
(
p
[
-
1
]))
--
p
;
*
p
=
0
;
return
src
;
...
...
src/util/CharUtil.hxx
View file @
db6db517
...
...
@@ -58,6 +58,19 @@ IsWhitespaceNotNull(const char ch)
return
ch
>
0
&&
ch
<=
0x20
;
}
/**
* Is the given character whitespace? This calls the faster one of
* IsWhitespaceOrNull() or IsWhitespaceNotNull(). Use this if you
* want the fastest implementation, and you don't care if a null byte
* matches.
*/
constexpr
static
inline
bool
IsWhitespaceFast
(
const
char
ch
)
{
return
IsWhitespaceOrNull
(
ch
);
}
constexpr
static
inline
bool
IsPrintableASCII
(
char
ch
)
...
...
src/util/Tokenizer.cxx
View file @
db6db517
...
...
@@ -67,7 +67,7 @@ Tokenizer::NextWord(Error &error)
whitespace or end-of-string */
while
(
*++
input
!=
0
)
{
if
(
IsWhitespace
OrNull
(
*
input
))
{
if
(
IsWhitespace
Fast
(
*
input
))
{
/* a whitespace: the word ends here */
*
input
=
0
;
/* skip all following spaces, too */
...
...
@@ -112,7 +112,7 @@ Tokenizer::NextUnquoted(Error &error)
whitespace or end-of-string */
while
(
*++
input
!=
0
)
{
if
(
IsWhitespace
OrNull
(
*
input
))
{
if
(
IsWhitespace
Fast
(
*
input
))
{
/* a whitespace: the word ends here */
*
input
=
0
;
/* skip all following spaces, too */
...
...
@@ -176,7 +176,7 @@ Tokenizer::NextString(Error &error)
line) */
++
input
;
if
(
!
IsWhitespace
OrNull
(
*
input
))
{
if
(
!
IsWhitespace
Fast
(
*
input
))
{
error
.
Set
(
tokenizer_domain
,
"Space expected after closing '
\"
'"
);
return
nullptr
;
...
...
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