mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
console,util: improve array inspection performance
There is no need to do the own property check, since the descriptor is needed right afterwards anyway. PR-URL: https://github.com/nodejs/node/pull/60037 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
parent
413693481f
commit
c2536adc28
|
|
@ -2281,11 +2281,12 @@ function formatArray(ctx, value, recurseTimes) {
|
|||
const remaining = valLen - len;
|
||||
const output = [];
|
||||
for (let i = 0; i < len; i++) {
|
||||
const desc = ObjectGetOwnPropertyDescriptor(value, i);
|
||||
if (desc === undefined) {
|
||||
// Special handle sparse arrays.
|
||||
if (!ObjectPrototypeHasOwnProperty(value, i)) {
|
||||
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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user