mirror of
https://github.com/mrclay/minify.git
synced 2025-08-08 15:16:56 +02:00
Perf update for JSmin (Minify_Javascript), + phpDocs for public HTTP_* class APIs, minor Minify fix, private members changed to protected to allow easier subclassing.
This commit is contained in:
@@ -87,17 +87,17 @@ class Minify_CSS {
|
||||
*
|
||||
* I.e. are some browsers targetted until the next comment?
|
||||
*/
|
||||
private static $_inHack = false;
|
||||
protected static $_inHack = false;
|
||||
|
||||
/**
|
||||
* @var string string to be prepended to relative URIs
|
||||
*/
|
||||
private static $_tempPrepend = '';
|
||||
protected static $_tempPrepend = '';
|
||||
|
||||
/**
|
||||
* @var string path of this stylesheet for rewriting purposes
|
||||
*/
|
||||
private static $_tempCurrentPath = '';
|
||||
protected static $_tempCurrentPath = '';
|
||||
|
||||
/**
|
||||
* Process what looks like a comment and return a replacement
|
||||
@@ -106,7 +106,7 @@ class Minify_CSS {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _commentCB($m)
|
||||
protected static function _commentCB($m)
|
||||
{
|
||||
$m = $m[1];
|
||||
// $m is everything after the opening tokens and before the closing tokens
|
||||
@@ -148,12 +148,12 @@ class Minify_CSS {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _selectorsCB($m)
|
||||
protected static function _selectorsCB($m)
|
||||
{
|
||||
return preg_replace('/\\s*([,>+~])\\s*/', '$1', $m[0]);
|
||||
}
|
||||
|
||||
private static function _urlCB($m)
|
||||
protected static function _urlCB($m)
|
||||
{
|
||||
$isImport = (0 === strpos($m[0], '@import'));
|
||||
if ($isImport) {
|
||||
|
@@ -54,7 +54,7 @@ class Minify_Controller_Page extends Minify_Controller_Base {
|
||||
return $options;
|
||||
}
|
||||
|
||||
private $_loadCssJsMinifiers = false;
|
||||
protected $_loadCssJsMinifiers = false;
|
||||
|
||||
/**
|
||||
* @see Minify_Controller_Base::loadMinifier()
|
||||
|
@@ -84,21 +84,21 @@ class Minify_HTML {
|
||||
return $html;
|
||||
}
|
||||
|
||||
private static $_isXhtml = false;
|
||||
private static $_replacementHash = null;
|
||||
private static $_pres = array();
|
||||
private static $_scripts = array();
|
||||
private static $_styles = array();
|
||||
private static $_cssMinifier = null;
|
||||
private static $_jsMinifier = null;
|
||||
protected static $_isXhtml = false;
|
||||
protected static $_replacementHash = null;
|
||||
protected static $_pres = array();
|
||||
protected static $_scripts = array();
|
||||
protected static $_styles = array();
|
||||
protected static $_cssMinifier = null;
|
||||
protected static $_jsMinifier = null;
|
||||
|
||||
private static function _removePreCB($m)
|
||||
protected static function _removePreCB($m)
|
||||
{
|
||||
self::$_pres[] = $m[1];
|
||||
return self::$_replacementHash . 'PRE' . count(self::$_pres);
|
||||
}
|
||||
|
||||
private static function _removeStyleCB($m)
|
||||
protected static function _removeStyleCB($m)
|
||||
{
|
||||
$openStyle = $m[1];
|
||||
$css = $m[2];
|
||||
@@ -123,7 +123,7 @@ class Minify_HTML {
|
||||
return self::$_replacementHash . 'STYLE' . count(self::$_styles);
|
||||
}
|
||||
|
||||
private static function _removeScriptCB($m)
|
||||
protected static function _removeScriptCB($m)
|
||||
{
|
||||
$openScript = $m[1];
|
||||
$js = $m[2];
|
||||
@@ -147,14 +147,14 @@ class Minify_HTML {
|
||||
return self::$_replacementHash . 'SCRIPT' . count(self::$_scripts);
|
||||
}
|
||||
|
||||
private static function _removeCdata($str)
|
||||
protected static function _removeCdata($str)
|
||||
{
|
||||
return (false !== strpos($str, '<![CDATA['))
|
||||
? str_replace(array('<![CDATA[', ']]>'), '', $str)
|
||||
: $str;
|
||||
}
|
||||
|
||||
private static function _needsCdata($str)
|
||||
protected static function _needsCdata($str)
|
||||
{
|
||||
return (self::$_isXhtml && preg_match('/(?:[<&]|\\-\\-|\\]\\]>)/', $str));
|
||||
}
|
||||
|
@@ -39,9 +39,9 @@
|
||||
* @package Minify_Javascript
|
||||
* @author Ryan Grove <ryan@wonko.com>
|
||||
* @copyright 2002 Douglas Crockford <douglas@crockford.com> (JSMin.c)
|
||||
* @copyright 2007 Ryan Grove <ryan@wonko.com> (PHP port)
|
||||
* @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
|
||||
* @license http://opensource.org/licenses/mit-license.php MIT License
|
||||
* @version 1.1.0 (2007-06-01)
|
||||
* @version 1.1.1 (2008-03-03)
|
||||
* @link http://code.google.com/p/jsmin-php/
|
||||
*/
|
||||
|
||||
@@ -55,7 +55,7 @@ class Minify_Javascript {
|
||||
private $inputIndex = 0;
|
||||
private $inputLength = 0;
|
||||
private $lookAhead = null;
|
||||
private $output = array();
|
||||
private $output = '';
|
||||
|
||||
// -- Public Static Methods --------------------------------------------------
|
||||
|
||||
@@ -74,15 +74,15 @@ class Minify_Javascript {
|
||||
private function action($d) {
|
||||
switch($d) {
|
||||
case 1:
|
||||
$this->output[] = $this->a;
|
||||
$this->output .= $this->a;
|
||||
|
||||
case 2:
|
||||
$this->a = $this->b;
|
||||
|
||||
if ($this->a === "'" || $this->a === '"') {
|
||||
for (;;) {
|
||||
$this->output[] = $this->a;
|
||||
$this->a = $this->get();
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
|
||||
if ($this->a === $this->b) {
|
||||
break;
|
||||
@@ -93,8 +93,8 @@ class Minify_Javascript {
|
||||
}
|
||||
|
||||
if ($this->a === '\\') {
|
||||
$this->output[] = $this->a;
|
||||
$this->a = $this->get();
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,25 +107,23 @@ class Minify_Javascript {
|
||||
$this->a === ':' || $this->a === '[' || $this->a === '!' ||
|
||||
$this->a === '&' || $this->a === '|' || $this->a === '?')) {
|
||||
|
||||
$this->output[] = $this->a;
|
||||
$this->output[] = $this->b;
|
||||
$this->output .= $this->a;
|
||||
$this->output .= $this->b;
|
||||
|
||||
for (;;) {
|
||||
$this->a = $this->get();
|
||||
|
||||
if ($this->a === '/') {
|
||||
break;
|
||||
}
|
||||
elseif ($this->a === '\\') {
|
||||
$this->output[] = $this->a;
|
||||
$this->a = $this->get();
|
||||
}
|
||||
elseif (ord($this->a) <= self::ORD_LF) {
|
||||
} elseif ($this->a === '\\') {
|
||||
$this->output .= $this->a;
|
||||
$this->a = $this->get();
|
||||
} elseif (ord($this->a) <= self::ORD_LF) {
|
||||
throw new Minify_JavascriptException('Unterminated regular expression '.
|
||||
'literal.');
|
||||
}
|
||||
|
||||
$this->output[] = $this->a;
|
||||
$this->output .= $this->a;
|
||||
}
|
||||
|
||||
$this->b = $this->next();
|
||||
@@ -141,8 +139,7 @@ class Minify_Javascript {
|
||||
if ($this->inputIndex < $this->inputLength) {
|
||||
$c = $this->input[$this->inputIndex];
|
||||
$this->inputIndex += 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$c = null;
|
||||
}
|
||||
}
|
||||
@@ -167,8 +164,7 @@ class Minify_Javascript {
|
||||
case ' ':
|
||||
if (self::isAlphaNum($this->b)) {
|
||||
$this->action(1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->action(2);
|
||||
}
|
||||
break;
|
||||
@@ -237,7 +233,7 @@ class Minify_Javascript {
|
||||
}
|
||||
}
|
||||
|
||||
return implode('', $this->output);
|
||||
return $this->output;
|
||||
}
|
||||
|
||||
private function next() {
|
||||
|
@@ -129,8 +129,8 @@ class Minify_Source {
|
||||
return 'text/plain';
|
||||
}
|
||||
|
||||
private $_content = null;
|
||||
private $_filepath = null;
|
||||
private $_id = null;
|
||||
protected $_content = null;
|
||||
protected $_filepath = null;
|
||||
protected $_id = null;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user