-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: improve typed array formatting #3793
Conversation
@@ -314,6 +315,28 @@ function formatValue(ctx, value, recurseTimes) { | |||
keys.unshift('size'); | |||
empty = value.size === 0; | |||
formatter = formatMap; | |||
} else if (value instanceof ArrayBuffer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.keys((new ArrayBuffer(5))).length === 0
. Should this be placed in the shortcut path above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nm. overlooked the other keys additions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah. so I wasn't loosing it:
Object.keys(new ArrayBuffer(5)).length === 0;
Object.getOwnPropertyNames(new ArrayBuffer(5)).length === 0;
Object.getOwnPropertySymbols(new ArrayBuffer(5)) === 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it here because it adds a key for .byteLength
but I can probably move it up and call formatProperty()
directly, likewise for DataView. Good idea / bad idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a fast path for ArrayBuffer, PTAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it.
LGTM |
Pretty-print typed arrays like regular arrays. Speeds up formatting by almost 300% because it no longer stringifies the array indices. Pretty-print ArrayBuffer and DataView as well by including byteLength, byteOffset and buffer properties in the stringified representation. PR-URL: nodejs#3793 Reviewed-By: Rod Vagg <[email protected]>
90fc91b
to
6cf2cff
Compare
Pretty-print typed arrays like regular arrays. Speeds up formatting by almost 300% because it no longer stringifies the array indices. Pretty-print ArrayBuffer and DataView as well by including byteLength, byteOffset and buffer properties in the stringified representation. PR-URL: nodejs#3793 Reviewed-By: Trevor Norris <[email protected]>
Thanks for review, landed in 34a3591. Apologies, I initially landed it with the wrong Reviewed-By tag. |
Pretty-print typed arrays like regular arrays. Speeds up formatting by
almost 300% because it no longer stringifies the array indices.
Pretty-print ArrayBuffer and DataView as well by including byteLength,
byteOffset and buffer properties in the stringified representation.
Taggging this semver-major for now. Maybe overcautious?
CI: https://ci.nodejs.org/job/node-test-pull-request/711/