Skip to content

Commit 1a1ea06

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

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

minify.json.php

Lines changed: 2 additions & 2 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,7 +25,6 @@ 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) {

0 commit comments

Comments
 (0)