File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ export function fromHex(str) {
7373 }
7474 }
7575
76- const codes = encodeAscii ( str , E_HEX )
76+ const codes = encodeAscii ( str , E_HEX ) // aligned
7777 const codes16 = new Uint16Array ( codes . buffer , codes . byteOffset , codes . byteLength / 2 )
7878 let i = 0
7979 for ( const last3 = length - 3 ; i < last3 ; i += 4 ) {
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ export const encodeAscii = useEncodeInto
140140 : nativeBuffer
141141 ? ( str , ERR ) => {
142142 // TextEncoder is slow on Node.js 24 / 25 (was ok on 22)
143+ // Node.js Buffer.from always returns 8-byte aligned allocations, this is safe for e.g. conversion to Uint32Array
143144 const codes = nativeBuffer . from ( str , 'utf8' ) // ascii/latin1 coerces, we need to check
144145 if ( codes . length !== str . length ) throw new SyntaxError ( ERR ) // non-ascii
145146 return new Uint8Array ( codes . buffer , codes . byteOffset , codes . byteLength )
You can’t perform that action at this time.
0 commit comments