Skip to content

Commit

Permalink
chore: performance improvement on asStringSmall (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
nigrosimone committed Mar 10, 2024
1 parent 1197be3 commit 64e163d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,8 @@ module.exports = class Serializer {
// eslint-disable-next-line
for (var i = 0; i < len; i++) {
point = str.charCodeAt(i)
if (point < 32) {
return JSON.stringify(str)
}
if (point >= 0xD800 && point <= 0xDFFF) {
// The current character is a surrogate.
if (point < 32 || (point >= 0xD800 && point <= 0xDFFF)) {
// The current character is non-printable characters or a surrogate.
return JSON.stringify(str)
}
if (
Expand Down

0 comments on commit 64e163d

Please sign in to comment.