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 df72dc9

Browse filesBrowse files
BridgeARaduh95
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 26394cd commit df72dc9
Copy full SHA for df72dc9

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
@@ -2022,11 +2022,12 @@ function formatArray(ctx, value, recurseTimes) {
20222022
const remaining = valLen - len;
20232023
const output = [];
20242024
for (let i = 0; i < len; i++) {
2025-
// Special handle sparse arrays.
2026-
if (!ObjectPrototypeHasOwnProperty(value, i)) {
2025+
const desc = ObjectGetOwnPropertyDescriptor(value, i);
2026+
if (desc === undefined) {
2027+
// Special handle sparse arrays.
20272028
return formatSpecialArray(ctx, value, recurseTimes, len, output, i);
20282029
}
2029-
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType));
2030+
ArrayPrototypePush(output, formatProperty(ctx, value, recurseTimes, i, kArrayType, desc));
20302031
}
20312032
if (remaining > 0) {
20322033
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.