Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reworked getChar for clarity and added more comments.

  • Loading branch information...
commit 74ad154fe1ef1ac0916e7f5de292536568b5a8da 1 parent 08001d1
@tedivm tedivm authored
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/JShrink/Minifier.php
View
18 src/JShrink/Minifier.php
@@ -238,21 +238,27 @@ protected function breakdownScript($js, $currentOptions)
*/
protected function getChar()
{
+ // Check to see if we had anything in the look ahead buffer and use that.
if (isset($this->c)) {
$char = $this->c;
unset($this->c);
+
+ // Otherwise we start pulling from the input.
} else {
- $tchar = substr($this->input, $this->index, 1);
- if (isset($tchar) && $tchar !== false) {
- $char = $tchar;
- $this->index++;
- } else {
+ $char = substr($this->input, $this->index, 1);
+
+ // If the next character doesn't exist return false.
+ if (isset($char) && $char === false) {
return false;
}
+
+ // Otherwise increment the pointer and use this char.
+ $this->index++;
}
+ // Normalize all whitespace except for the newline character into a
+ // standard space.
if($char !== "\n" && ord($char) < 32)
-
return ' ';
return $char;
Please sign in to comment.
Something went wrong with that request. Please try again.