Skip to content

Commit

Permalink
chore: only use the regular expression for shorter input. The overhea…
Browse files Browse the repository at this point in the history
…d is otherwise too much. (#691)
  • Loading branch information
nigrosimone committed Mar 12, 2024
1 parent dfb627e commit d154bf5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ module.exports = class Serializer {
asString (str) {
if (str.length < 42) {
return this.asStringSmall(str)
} else if (STR_ESCAPE.test(str) === false) {
} else if (str.length < 5000 && STR_ESCAPE.test(str) === false) {
// Only use the regular expression for shorter input. The overhead is otherwise too much.
return '"' + str + '"'
} else {
return JSON.stringify(str)
Expand Down

0 comments on commit d154bf5

Please sign in to comment.