-
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: escaping object keys in util.inspect() #16986
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not specific to this PR but to the code:
@bmeurer in my tests
RegExp.p.test
performs better thanString.p.replace
. Should those not be on par in case no match is found? And with small strings it is (last tested with 6.1) still better to useString.p.charCodeAt
instead of the RegExp. Is there any chance to improve the RegExp so it would match the performance ofcharCodeAt
?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.
test
is a much simpler operation than@@replace
(see the spec at [0] and [1]). It's fairly easy to implementtest
efficiently; but in my experience@@replace
is another story, see V8's@@replace
dispatch logic at [2] to feel our pain.In this particular case, we seem to reach the
ReplaceGlobalCallableFastPath
. There's definitely a couple of things we could do to improve here, like remove one (or both) runtime calls. Could you open a bug at crbug.com/v8/new?[0] https://tc39.github.io/ecma262/#sec-regexp.prototype.test
[1] https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
[2] https://cs.chromium.org/chromium/src/v8/src/builtins/builtins-regexp-gen.cc?l=3058&rcl=2eea37273b30caa5cedf3a5c8d656860bc60320b
I assume you mean
charCodeAt
vs.test
? It'll be hard to beat, sincecharCodeAt
is completely inlined by the optimizing compiler. I suppose one possible step we could take would be to eliminate the call overhead from RegExp builtins, but I wouldn't expect performance to improve by alot.Could you share the benchmark you used to measure this?
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.
Went ahead and created https://crbug.com/v8/7081.