-
-
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: use regexp in string escaping #553
Conversation
c6408cf
to
c683091
Compare
@@ -94,6 +97,10 @@ module.exports = class Serializer { | |||
str = str.toString() | |||
} | |||
|
|||
if (!STR_ESCAPE.test(str)) { |
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.
Could you please include a comment above this line telling why it's needed?
@@ -94,6 +97,11 @@ module.exports = class Serializer { | |||
str = str.toString() | |||
} | |||
|
|||
// Fast escape chars check | |||
if (!STR_ESCAPE.test(str)) { |
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.
This new check does not execute the str.length < 42
optimization. Is this wanted or could we go even faster?
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
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.
Do you want some perf upgrades? I've got something for you.