perf(encoding): fix loop times in encodeHex() (#5344)

This commit is contained in:
Mannix 2024-07-08 09:36:00 +08:00 committed by GitHub
parent ab0dd78b17
commit 1a637a71a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,7 +71,7 @@ export function encodeHex(src: string | Uint8Array | ArrayBuffer): string {
const u8 = validateBinaryLike(src);
const dst = new Uint8Array(u8.length * 2);
for (let i = 0; i < dst.length; i++) {
for (let i = 0; i < u8.length; i++) {
const v = u8[i]!;
dst[i * 2] = hexTable[v >> 4]!;
dst[i * 2 + 1] = hexTable[v & 0x0f]!;