-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
perf: fast regex check on string #696
Conversation
Signed-off-by: francesco <[email protected]>
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.
lgtm
Side node, also merged into the "origin" project of the regex BridgeAR/fast-json-escape#6 @mcollina this PR is a good perfrmance improvent (the other I have made are just micro-optimization), please, I need some attention here. |
What attention do you need? |
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.
lgtm - good catch
@mcollina Because it seem a good improvement on long string parsing (from 2.2% to 5.8), I would like to get this PR into the master's as quickly as possible. |
The regex
can be
The first part of alternation (
[\u0000-\u001f\u0022\u005c\ud800-\udfff]
) will match anything that might have been matched by the second ([\ud800-\udbff](?![\udc00-\udfff])
) and third part ((?:[^\ud800-\udbff]|^)[\udc00-\udfff]
).I have made this simple online test for play with both rule (https://jsfiddle.net/nd84e7fz/):
output
The two rule works in the same manner!
benchmark only regex execution
benchmark fast-json-stringify (
npm run bench
) with focus on long stringmaster
PR
DIFF
Checklist
npm run test
andnpm run benchmark
and the Code of conduct