Skip to content

Commit ac74550

Browse files
committed
Add all NEON registers if ASCII, then bad byte is drop false
if all registers (16 bytes) lower than 0x7F, assumed to be ASCII.
1 parent 5ed2099 commit ac74550

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/mbstring/mbstring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4908,9 +4908,10 @@ static bool mb_fast_check_utf8_default(zend_string *str)
49084908
for (; i <= len - 16; i += 16) {
49094909
int8x16_t current_bytes = vld1q_s8((int8_t *)(p + i));
49104910
/* top bit is all 0, it is ASCII */
4911-
if (vmaxvq_u8(vreinterpretq_u8_s8(vshrq_n_s8(current_bytes, 8))) == 0) {
4911+
int8x16_t is_ascii = vreinterpretq_s8_u8(vqsubq_u8(vreinterpretq_u8_s8(current_bytes), vdupq_n_u8(0x7F)));
4912+
if (vmaxvq_u8(is_ascii) == 0) {
49124913
int8x16_t bad = vceqq_s8(vandq_s8(previous.rawbytes, bad_mask_prev_not_ascii), bad_mask_prev_not_ascii);
4913-
if (vmaxvq_u8(vreinterpretq_u8_s8(bad))) {
4914+
if (vmaxvq_u8(vreinterpretq_u8_s8(bad)) != 0) {
49144915
return false;
49154916
}
49164917
}

0 commit comments

Comments
 (0)