diff --git a/.changeset/green-snakes-try.md b/.changeset/green-snakes-try.md new file mode 100644 index 0000000..083afa8 --- /dev/null +++ b/.changeset/green-snakes-try.md @@ -0,0 +1,5 @@ +--- +'multitars': patch +--- + +Replace `parseInt(val, 8)` for octal parsing with manual parsing (hotpath) diff --git a/src/tarInput.ts b/src/tarInput.ts index ffd5a56..b878e3d 100644 --- a/src/tarInput.ts +++ b/src/tarInput.ts @@ -146,8 +146,9 @@ function decodeOctal(bytes: Uint8Array, from: number, to: number): number { } else { idx = from; while (idx < to && (bytes[idx] === 32 || bytes[idx] === 0)) idx++; - if (end !== idx) val = parseInt(decodeString(bytes, idx, to), 8); - return val == val ? val || 0 : 0; + while (idx < to && bytes[idx] >= 48 && bytes[idx] <= 55) + val = val * 8 + (bytes[idx++] - 48); + return val; } }