Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0bf022d

Browse filesBrowse files
BridgeARtargos
authored andcommitted
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: #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>
1 parent d949222 commit 0bf022d
Copy full SHA for 0bf022d

File tree

Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed
Open diff view settings
Collapse file

‎lib/internal/util/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,11 +2029,12 @@ function formatArray(ctx, value, recurseTimes) {
20292029
const remaining = valLen - len;
20302030
const output = [];
20312031
for (let i = 0; i < len; i++) {
2032-
// Special handle sparse arrays.
2033-
if (!ObjectPrototypeHasOwnProperty(value, i)) {
2032+
const desc = ObjectGetOwnPropertyDescriptor(value, i);
2033+
if (desc === undefined) {
2034+
// Special handle sparse arrays.
20342035
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
20352036
}
2036-
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType));
2037+
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType, desc));
20372038
}
20382039
if (remaining > 0) {
20392040
ArrayPrototypePush(output, remainingText(remaining));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.