| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Hello @buji1993 and welcome. Thank you very much for the contribution 🥇 P.S. If you have any question you can also feel free to contact me directly (here, on IRC, or anywhere else). |
Sorry, something went wrong.
| '{ \'\\\\\': 2, \'\\\\\\\\\': 4, \'\\\\\\\\\\\\\': 6, ' + | ||
| '\'\\\\\\\\\\\\\\\\\': 8 }' | ||
| ); | ||
| assert.strictEqual( |
There was a problem hiding this comment.
Suggestion, could you add a test with \r and \n
Sorry, something went wrong.
There was a problem hiding this comment.
thanks for your suggestion, I will add it later
Sorry, something went wrong.
|
Is this semver-major? It seems like a bugfix, but it changes outputs. |
Sorry, something went wrong.
|
I'd argue for bug fix, but once we land, we might want to wait a while before backporting to LTS |
Sorry, something went wrong.
| if (str.length < 5000 && !keyEscapeSequencesRegExp.test(str)) | ||
| return `'${str}'`; | ||
| if (str.length > 100) | ||
| return `'${str.replace(keyEscapeSequencesReplacer, escapeFn)}'`; |
There was a problem hiding this comment.
Not specific to this PR but to the code:
@bmeurer in my tests RegExp.p.test performs better than String.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 use String.p.charCodeAt instead of the RegExp. Is there any chance to improve the RegExp so it would match the performance of charCodeAt?
Sorry, something went wrong.
There was a problem hiding this comment.
@bmeurer in my tests RegExp.p.test performs better than String.p.replace. Should those not be on par in case no match is found?
test is a much simpler operation than @@replace (see the spec at [0] and [1]). It's fairly easy to implement test 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
And with small strings it is (last tested with 6.1) still better to use String.p.charCodeAt instead of the RegExp. Is there any chance to improve the RegExp so it would match the performance of charCodeAt?
I assume you mean charCodeAt vs. test? It'll be hard to beat, since charCodeAt 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?
Sorry, something went wrong.
There was a problem hiding this comment.
Could you open a bug at crbug.com/v8/new?
Went ahead and created https://crbug.com/v8/7081.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Seems like the original reason for this was another bug (nodejs/node-v0.x-archive#6835) that was fixed with a not ideal solution.
Sorry, something went wrong.
|
@refack thanks, it's so nice! I will contact you if I need help |
Sorry, something went wrong.
|
@schuay is probably a good person to answer this question. |
Sorry, something went wrong.
There was a problem hiding this comment.
PRs that fix a bug by removing code are my favourite. 🥇
Sorry, something went wrong.
Sorry, something went wrong.
|
as this may have unexpected breakages we are waiting a bit before landing on lts |
Sorry, something went wrong.
|
@MylesBorins we now got this in 9 for a while without any complains I think we can go ahead and backport this. I added the backport requested label but it might actually apply cleanly? |
Sorry, something went wrong.
|
@BridgeAR the land-on label is used once something has been landed. 😄 edit: I've landed in" |
Sorry, something went wrong.
|
I've opted to not land on v6.x. Please feel free to change labels and open backport |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes: #16979
Checklist
Affected core subsystem(s)
lib