You are here

protected function Minifier::getReal in Advanced CSS/JS Aggregation 8.4

Same name and namespace in other branches
  1. 8.2 advagg_js_minify/jshrink.inc \JShrink\Minifier::getReal()
  2. 8.3 advagg_js_minify/jshrink.inc \JShrink\Minifier::getReal()
  3. 7.2 advagg_js_compress/jshrink.inc \JShrink\Minifier::getReal()

This function gets the next "real" character. It is essentially a wrapper around the getChar function that skips comments. This has significant performance benefits as the skipping is done using native functions (ie, c code) rather than in script php.

Return value

string Next 'real' character to be processed.

Throws

\RuntimeException

3 calls to Minifier::getReal()
Minifier::initialize in advagg_js_minify/jshrink.inc
Initializes internal variables, normalizes new lines,
Minifier::loop in advagg_js_minify/jshrink.inc
The primary action occurs here. This function loops through the input string, outputting anything that's relevant and discarding anything that is not.
Minifier::saveRegex in advagg_js_minify/jshrink.inc
When a regular expression is detected this function crawls for the end of it and saves the whole regex.

File

advagg_js_minify/jshrink.inc, line 344

Class

Minifier
Minifier

Namespace

JShrink

Code

protected function getReal() {
  $startIndex = $this->index;
  $char = $this
    ->getChar();

  // Check to see if we're potentially in a comment
  if ($char !== '/') {
    return $char;
  }
  $this->c = $this
    ->getChar();
  if ($this->c === '/') {
    return $this
      ->processOneLineComments($startIndex);
  }
  elseif ($this->c === '*') {
    return $this
      ->processMultiLineComments($startIndex);
  }
  return $char;
}