Skip to content

Commit 8145afa

Browse files
committed
tweaking to just copy less string, which should give better perf
1 parent c642588 commit 8145afa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

minify.json.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ function json_minify($json) {
1515
while (preg_match($tokenizer,$json,$tmp,PREG_OFFSET_CAPTURE,$lastIndex)) {
1616
$tmp = $tmp[0];
1717
$lastIndex = $tmp[1] + strlen($tmp[0]);
18-
$lc = substr($json,0,$lastIndex - strlen($tmp[0]));
18+
$prevFrom = $from;
19+
$lc = substr($json,$prevFrom,$lastIndex - strlen($tmp[0]));
1920
$rc = substr($json,$lastIndex);
2021
if (!$in_multiline_comment && !$in_singleline_comment) {
2122
$tmp2 = substr($lc,$from);
@@ -24,11 +25,10 @@ function json_minify($json) {
2425
}
2526
$new_str[] = $tmp2;
2627
}
27-
$prevFrom = $from;
2828
$from = $lastIndex;
2929

3030
if ($tmp[0] == "\"" && !$in_multiline_comment && !$in_singleline_comment) {
31-
preg_match("/(\\\\)*$/",$lc,$tmp2,PREG_PATTERN_ORDER,$prevFrom);
31+
preg_match("/(\\\\)*$/",$lc,$tmp2);
3232
if (!$in_string || !$tmp2 || (strlen($tmp2[0]) % 2) == 0) { // start of string with ", or unescaped " character found to end string
3333
$in_string = !$in_string;
3434
}

0 commit comments

Comments
 (0)