mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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>
This commit is contained in:
1 parent
598aa2941b
commit
cadf10a9ce
1 file changed
+1
-2
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user