Skip to content

Commit

Permalink
fixing performance bug (see #64) in Java implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
getify committed Dec 15, 2021
1 parent f7b606b commit 21e5531
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/io/github/getify/minify/Minify.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static String minify(CharSequence json) {
String tmp2;
StringBuilder new_str = new StringBuilder();
Integer from = 0;
Integer prevFrom;
String lc;
String rc = "";

Expand All @@ -63,11 +64,12 @@ public static String minify(CharSequence json) {

new_str.append(tmp2);
}
prevFrom = from;
from = matcher.end();

if (tmp.charAt(0) == '\"' && !in_multiline_comment && !in_singleline_comment) {
magicMatcher = MAGIC_PATTERN.matcher(lc);
foundMagic = magicMatcher.find();
foundMagic = magicMatcher.find(prevFrom);
if (!in_string || !foundMagic || (magicMatcher.end() - magicMatcher.start()) % 2 == 0) {
in_string = !in_string;
}
Expand Down

0 comments on commit 21e5531

Please sign in to comment.