From b84f22244a9c4b912e49904043ab73c8a9ed19ee Mon Sep 17 00:00:00 2001 From: Roberto Bianchi Date: Mon, 23 Nov 2026 18:01:47 +0100 Subject: [PATCH] lib: use indexed append in ZIP central directory parser readCentralDirectory() appends one CentralFileHeader per archive entry with ArrayPrototypePush, which is listed among primordials with known performance issues. Assign by the existing loop index instead. The loop runs once per entry, so its trip count grows with archive size. The change is limited to this loop. Validation and error behavior are unchanged. Assisted-by: Claude Code Signed-off-by: Roberto Bianchi --- lib/internal/zip/headers.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/zip/headers.js b/lib/internal/zip/headers.js index bf6f7901516a..3bcb81f23dd5 100644 --- a/lib/internal/zip/headers.js +++ b/lib/internal/zip/headers.js @@ -6,7 +6,6 @@ // which walks the central directory into an array of headers. const { - ArrayPrototypePush, MathMax, Number, } = primordials; @@ -604,7 +603,7 @@ function readCentralDirectory(buffer, count) { if (header.diskNumber !== 0) { throw new ERR_ZIP_UNSUPPORTED_FEATURE('multi-disk archives are not supported'); } - ArrayPrototypePush(result, header); + result[index] = header; pos += header.byteLength; } if (pos !== buffer.length) {