Commit a33756670d2 for nodejs
commit a33756670d23cf4410a800e62499bf40072e1ff5
Author: Roberto Bianchi <roberto.bianchi@spendesk.com>
Date: Tue Nov 24 10:41:47 2026 +0100
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 <roberto.bianchi@spendesk.com>
PR-URL: https://github.com/nodejs/node/pull/67456
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>
diff --git a/lib/internal/zip/headers.js b/lib/internal/zip/headers.js
index bf6f7901516..3bcb81f23dd 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) {