Optimized javascript compressor.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 31 Aug 2009 13:49:32 +0000 (13:49 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 31 Aug 2009 13:49:32 +0000 (13:49 +0000)
includes/main.inc

index b1876099aff2346b8b4020a189cdb296697e190d..8c0fc8d3c9f42933f27cdcfb7d0fd9b692a35564 100644 (file)
@@ -141,10 +141,11 @@ function js_compress($sJS)
                $inNormalComment = false;
        
                //loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
-               for($j=0;$j<strlen($line);$j++)
+               $len = strlen($line);
+               for($j=0;$j<$len;$j++)
                {
-                       $c = substr($line,$j,1);
-                       $d = substr($line,$j,2);
+                       $c = $line[$j];         // this is _really_ faster than subst
+                       $d = $c.$line[$j+1];
        
                        //look for start of quote
                        if(!$inQuote && !$inComment)