Skip to content

Commit f3b2330

Browse files
committed
Remove rtrim loop
1 parent e981b5d commit f3b2330

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

ext/mbstring/mbstring.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,24 +2968,18 @@ static zend_string* trim_each_wchar(zend_string *str, const HashTable *what_ht,
29682968
ZEND_ASSERT(out_len <= 128);
29692969
total_len += out_len;
29702970

2971-
if (mode & MB_LTRIM) {
2972-
for (size_t i = 0; i < out_len; i++) {
2973-
uint32_t w = wchar_buf[i];
2974-
if (is_trim_wchar(w, what_ht)) {
2971+
for (size_t i = 0; i < out_len; i++) {
2972+
uint32_t w = wchar_buf[i];
2973+
if (is_trim_wchar(w, what_ht)) {
2974+
if (mode & MB_LTRIM) {
29752975
left += 1;
2976-
} else {
2977-
mode ^= MB_LTRIM;
2978-
break;
29792976
}
2980-
}
2981-
}
2982-
2983-
if (mode & MB_RTRIM) {
2984-
for (size_t j = 0; j < out_len; j++) {
2985-
uint32_t w = wchar_buf[j];
2986-
if (is_trim_wchar(w, what_ht)) {
2977+
if (mode & MB_RTRIM) {
29872978
right += 1;
2988-
} else {
2979+
}
2980+
} else {
2981+
mode &= ~MB_LTRIM;
2982+
if (mode & MB_RTRIM) {
29892983
right = 0;
29902984
}
29912985
}

0 commit comments

Comments
 (0)