@@ -71,15 +71,17 @@ export function deserializeString_SIMD(srcStart: usize, srcEnd: usize): string {
7171 const block = load < v128 > ( srcStart ) ;
7272 store < v128 > ( bs . offset , block ) ;
7373
74- const eq5C = i16x8 . eq ( load < v128 > ( srcStart ) , SPLAT_5C ) ;
75- let mask = i16x8 . bitmask ( eq5C ) ;
74+ const eq5C = i16x8 . eq ( block , SPLAT_5C ) ;
75+
7676 // Early exit
77- if ( mask === 0 ) {
77+ if ( ! v128 . any_true ( eq5C ) ) {
7878 srcStart += 16 ;
7979 bs . offset += 16 ;
8080 continue ;
8181 }
8282
83+ let mask = i16x8 . bitmask ( eq5C ) ;
84+
8385 let srcChg : usize = 0 ;
8486 let lastLane : usize = 0 ;
8587 do {
@@ -157,40 +159,3 @@ export function deserializeString_SIMD(srcStart: usize, srcEnd: usize): string {
157159
158160 return bs . out < string > ( ) ;
159161}
160-
161- /**
162- * Computes a per-lane mask identifying UTF-16 code units whose **low byte**
163- * is the ASCII backslash (`'\\'`, 0x5C).
164- *
165- * The mask is produced in two stages:
166- * 1. Detects bytes equal to 0x5C using a SWAR equality test.
167- * 2. Clears matches where 0x5C appears in the **high byte** of a UTF-16 code unit,
168- * ensuring only valid low-byte backslashes are reported.
169- *
170- * Each matching lane sets itself to 0x80.
171- */
172- // @ts -ignore: decorator
173- @inline function backslash_mask ( block : u64 ) : u64 {
174- const b = block ^ 0x005C_005C_005C_005C ;
175- const backslash_mask = ( b - 0x0001_0001_0001_0001 ) & ~ b & 0x0080_0080_0080_0080 ;
176- const high_byte_mask =
177- ~ ( ( ( block - 0x0100_0100_0100_0100 ) & ~ block & 0x8000_8000_8000_8000 )
178- ^ 0x8000_8000_8000_8000 ) >> 8 ;
179- return backslash_mask & high_byte_mask ;
180- }
181-
182- /**
183- * Computes a per-lane mask identifying UTF-16 code units whose **low byte**
184- * is the ASCII backslash (`'\\'`, 0x5C).
185- *
186- * Each matching lane sets itself to 0x80.
187- *
188- * WARNING: The low byte of a code unit *may* be a backslash, thus triggering false positives!
189- * This is useful for a hot path where it is possible to detect the false positive scalarly.
190- */
191- // @ts -ignore: decorator
192- @inline function backslash_mask_unsafe ( block : u64 ) : u64 {
193- const b = block ^ 0x005C_005C_005C_005C ;
194- const backslash_mask = ( b - 0x0001_0001_0001_0001 ) & ~ b & 0x0080_0080_0080_0080 ;
195- return backslash_mask ;
196- }
0 commit comments