Skip to content
Browse files

Preserve short variable names between versions if possible

  • Loading branch information...
1 parent b7e1cb0 commit 0ced6d33ceccc21824ba85072d93cf08701c97b3 @vrana committed Aug 9, 2011
Showing with 7 additions and 1 deletion.
  1. +7 −1 compile.php
View
8 compile.php
@@ -115,8 +115,14 @@ function php_shrink($input) {
}
arsort($short_variables);
+ $chars = implode(range('a', 'z')) . '_' . implode(range('A', 'Z'));
+ // preserve variable names between versions if possible
+ $short_variables2 = array_splice($short_variables, strlen($chars));
+ ksort($short_variables);
+ ksort($short_variables2);
+ $short_variables += $short_variables2;
foreach (array_keys($short_variables) as $number => $key) {
- $short_variables[$key] = short_identifier($number, implode(range('a', 'z')) . '_' . implode(range('A', 'Z'))); // could use also numbers and \x7f-\xff
+ $short_variables[$key] = short_identifier($number, $chars); // could use also numbers and \x7f-\xff
}
$set = array_flip(preg_split('//', '!"#$&\'()*+,-./:;<=>?@[\]^`{|}'));

0 comments on commit 0ced6d3

Please sign in to comment.
Something went wrong with that request. Please try again.