mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05: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:
1 parent
d949222043
commit
0bf022d4c0
1 file changed
+4
-3
@@ -2029,11 +2029,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));
|
||||
|
||||
Reference in new issue
Block a user