Skip to content

Commit f0818cc

Browse files
committed
refactor using zend_always_inline
1 parent 0d79226 commit f0818cc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

ext/standard/string.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ static inline zend_result php_charmask(const unsigned char *input, size_t len, c
515515
}
516516
/* }}} */
517517

518+
static zend_always_inline bool php_is_whitespace(unsigned char c)
519+
{
520+
return c <= ' ' && (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0');
521+
}
522+
518523
/* {{{ php_trim_int()
519524
* mode 1 : trim left
520525
* mode 2 : trim right
@@ -573,10 +578,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
573578
} else {
574579
if (mode & 1) {
575580
while (start != end) {
576-
unsigned char c = (unsigned char)*start;
577-
578-
if (c <= ' ' &&
579-
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
581+
if (php_is_whitespace((unsigned char)*start)) {
580582
start++;
581583
} else {
582584
break;
@@ -585,10 +587,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, const char
585587
}
586588
if (mode & 2) {
587589
while (start != end) {
588-
unsigned char c = (unsigned char)*(end-1);
589-
590-
if (c <= ' ' &&
591-
(c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v' || c == '\0')) {
590+
if (php_is_whitespace((unsigned char)*(end-1))) {
592591
end--;
593592
} else {
594593
break;

0 commit comments

Comments
 (0)