Skip to content

Commit

Permalink
per #64, more fixes to address significant performance concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
getify committed Dec 22, 2021
1 parent 4bcb4d0 commit 5cfc1d0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions minify.json.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! JSON.minify()
v0.2 (c) Kyle Simpson
v3.0.0 (c) Kyle Simpson
MIT License
*/

Expand All @@ -26,7 +26,7 @@
if (!in_multiline_comment && !in_singleline_comment) {
tmp2 = lc.substring(from);
if (!in_string) {
tmp2 = tmp2.replace(/(\n|\r|\s)*/g,"");
tmp2 = tmp2.replace(/(\n|\r|\s)+/g,"");
}
new_str[ns++] = tmp2;
}
Expand All @@ -37,14 +37,12 @@
// a comment? check for previous `\` escaping immediately
// leftward adjacent to this match
if (tmp[0] == "\"" && !in_multiline_comment && !in_singleline_comment) {
// perform look-behind escaping match, but
// limit left-context matching to only go back
// to the position of the last token match
//
// see: https://github.com/getify/JSON.minify/issues/64
lc.lastIndex = prevFrom;

// perform leftward adjacent escaping match
tmp2 = lc.match(/(\\)*$/);
tmp2 = lc.substring(prevFrom).match(/\\+$/);

// start of string with ", or unescaped " character found to end string?
if (!in_string || !tmp2 || (tmp2[0].length % 2) == 0) {
Expand Down

0 comments on commit 5cfc1d0

Please sign in to comment.