Skip to content

Commit 64e163d

Browse files
authored
chore: performance improvement on asStringSmall (#688)
1 parent 1197be3 commit 64e163d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/serializer.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,8 @@ module.exports = class Serializer {
141141
// eslint-disable-next-line
142142
for (var i = 0; i < len; i++) {
143143
point = str.charCodeAt(i)
144-
if (point < 32) {
145-
return JSON.stringify(str)
146-
}
147-
if (point >= 0xD800 && point <= 0xDFFF) {
148-
// The current character is a surrogate.
144+
if (point < 32 || (point >= 0xD800 && point <= 0xDFFF)) {
145+
// The current character is non-printable characters or a surrogate.
149146
return JSON.stringify(str)
150147
}
151148
if (

0 commit comments

Comments
 (0)