Skip to content

Commit d154bf5

Browse files
authored
chore: only use the regular expression for shorter input. The overhead is otherwise too much. (#691)
1 parent dfb627e commit d154bf5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/serializer.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ module.exports = class Serializer {
101101
asString (str) {
102102
if (str.length < 42) {
103103
return this.asStringSmall(str)
104-
} else if (STR_ESCAPE.test(str) === false) {
104+
} else if (str.length < 5000 && STR_ESCAPE.test(str) === false) {
105+
// Only use the regular expression for shorter input. The overhead is otherwise too much.
105106
return '"' + str + '"'
106107
} else {
107108
return JSON.stringify(str)

0 commit comments

Comments
 (0)