Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ export class Array extends NestedXdrType {
);
}
NestedXdrType.checkDepth(remainingDepth);
// allocate array of specified length
const result = new global.Array(this._length);
const result = [];
// read values
for (let i = 0; i < this._length; i++) {
result[i] = this._childType.read(reader, remainingDepth - 1);
result.push(this._childType.read(reader, remainingDepth - 1));
Comment on lines +25 to +28
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description claims this change improves memory performance for large arrays, but the diff switches from pre-sizing to incremental push, which changes allocation/growth behavior and may affect perf/memory depending on engine and size. Consider updating the PR description to reflect the actual motivation (e.g., avoiding holey arrays) and/or include benchmark results to support the stated memory claim.

Copilot uses AI. Check for mistakes.
}
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/var-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export class VarArray extends NestedXdrType {
);
}

const result = new Array(length);
const result = [];
for (let i = 0; i < length; i++) {
result[i] = this._childType.read(reader, remainingDepth - 1);
result.push(this._childType.read(reader, remainingDepth - 1));
}
return result;
}
Expand Down