Skip to content
Closed
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
console,util: improve array inspection performance
There is no need to do the own property check, since the descriptor
is needed right afterwards anyway.
  • Loading branch information
BridgeAR committed Sep 27, 2025
commit 98f4a1caf1eaab233a13b30cefd5df912bd28c21
7 changes: 4 additions & 3 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2271,11 +2271,12 @@ function formatArray(ctx, value, recurseTimes) {
const remaining = valLen - len;
const output = [];
for (let i = 0; i < len; i++) {
// Special handle sparse arrays.
if (!ObjectPrototypeHasOwnProperty(value, i)) {
const desc = ObjectGetOwnPropertyDescriptor(value, i);
if (desc === undefined) {
// Special handle sparse arrays.
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
}
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType));
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType, desc));
}
if (remaining > 0) {
ArrayPrototypePush(output, remainingText(remaining));
Expand Down
Loading