Skip to content

Commit 98f4a1c

Browse files
committed
console,util: improve array inspection performance
There is no need to do the own property check, since the descriptor is needed right afterwards anyway.
1 parent f6ea5bf commit 98f4a1c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/internal/util/inspect.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,11 +2271,12 @@ function formatArray(ctx, value, recurseTimes) {
22712271
const remaining = valLen - len;
22722272
const output = [];
22732273
for (let i = 0; i < len; i++) {
2274-
// Special handle sparse arrays.
2275-
if (!ObjectPrototypeHasOwnProperty(value, i)) {
2274+
const desc = ObjectGetOwnPropertyDescriptor(value, i);
2275+
if (desc === undefined) {
2276+
// Special handle sparse arrays.
22762277
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
22772278
}
2278-
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType));
2279+
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType, desc));
22792280
}
22802281
if (remaining > 0) {
22812282
ArrayPrototypePush(output, remainingText(remaining));

0 commit comments

Comments
 (0)