Skip to content

Commit 40ecd32

Browse files
committed
Add ASCII check for NEON UTF-8 check.
Lower than 0x7F that all bytes SIMD register, then reset previous struct.
1 parent ac74550 commit 40ecd32

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ext/mbstring/mbstring.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,13 +4907,13 @@ static bool mb_fast_check_utf8_default(zend_string *str)
49074907
if (len >= 16) {
49084908
for (; i <= len - 16; i += 16) {
49094909
int8x16_t current_bytes = vld1q_s8((int8_t *)(p + i));
4910-
/* top bit is all 0, it is ASCII */
4910+
/* All bytes are lower than 0x7F, it is ASCII */
49114911
int8x16_t is_ascii = vreinterpretq_s8_u8(vqsubq_u8(vreinterpretq_u8_s8(current_bytes), vdupq_n_u8(0x7F)));
49124912
if (vmaxvq_u8(is_ascii) == 0) {
4913-
int8x16_t bad = vceqq_s8(vandq_s8(previous.rawbytes, bad_mask_prev_not_ascii), bad_mask_prev_not_ascii);
4914-
if (vmaxvq_u8(vreinterpretq_u8_s8(bad)) != 0) {
4915-
return false;
4916-
}
4913+
previous.rawbytes = vdupq_n_s8(0);
4914+
previous.high_nibbles = vdupq_n_s8(0);
4915+
previous.carried_continuations = vdupq_n_s8(0);
4916+
continue;
49174917
}
49184918
neon_check_utf8_bytes(current_bytes, &previous, &has_error);
49194919
}

0 commit comments

Comments
 (0)