Size reduction by minification of variables
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@579 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
e8f1ddcee5
commit
a06f4c1521
26
_compile.php
26
_compile.php
|
@ -65,8 +65,22 @@ function put_file($match) {
|
|||
return $return;
|
||||
}
|
||||
|
||||
function short_variable($number) {
|
||||
$chars = implode("", range('a', 'z')) . '_' . implode("", range('A', 'Z')); // could use also numbers and \x7f-\xff
|
||||
$return = '$';
|
||||
while ($number >= 0) {
|
||||
$return .= $chars{$number % strlen($chars)};
|
||||
$number = floor($number / strlen($chars)) - 1;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Dgx's PHP shrinker
|
||||
function php_shrink($input) {
|
||||
$special_variables = array_flip(array('$TOKENS', '$this', '$GLOBALS', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_SERVER'));
|
||||
static $short_variables = array();
|
||||
$shortening = true;
|
||||
|
||||
$set = array_flip(preg_split('//', '!"#$&\'()*+,-./:;<=>?@[\]^`{|}'));
|
||||
$space = '';
|
||||
$output = '';
|
||||
|
@ -77,6 +91,18 @@ function php_shrink($input) {
|
|||
if ($token[0] == T_COMMENT || $token[0] == T_WHITESPACE) {
|
||||
$space = "\n";
|
||||
} else {
|
||||
if ($token[0] == T_VAR) {
|
||||
$shortening = false;
|
||||
} elseif (!$shortening) {
|
||||
if ($token[1] == ';') {
|
||||
$shortening = true;
|
||||
}
|
||||
} elseif ($token[0] == T_VARIABLE && !isset($special_variables[$token[1]])) {
|
||||
if (!isset($short_variables[$token[1]])) {
|
||||
$short_variables[$token[1]] = short_variable(count($short_variables));
|
||||
}
|
||||
$token[1] = $short_variables[$token[1]];
|
||||
}
|
||||
if (isset($set[substr($output, -1)]) || isset($set[$token[1]{0}])) {
|
||||
$space = '';
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ Cross links to select and table (bug #2236232), link new item
|
|||
Suhosin compatibility (thanks to Klemens Hackel)
|
||||
Remove max_allowed_packet from export
|
||||
Read style from phpMinAdmin.css if exists
|
||||
Size reduction by minification of variables
|
||||
|
||||
phpMinAdmin 1.9.1:
|
||||
Update translations
|
||||
|
|
Loading…
Reference in a new issue