ITADN

perf: rewrite src/uft8.ts using TextDecoder

#585Openrwv 创建于 2025-05-12
R
rwvcommented
You can rewrite `src/utf8.ts` using [TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) for better performance and robustness. ``` ts /** Converts a string to an array of UTF8 bytes. */ export function utf8Array(value: string) { const encoder = new TextEncoder(); const uint8Array = encoder.encode(value); const buffer = new Int32Array(uint8Array.buffer); return buffer; } ```
1 条评论