Skip to content

Commit

Permalink
Small performance optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubOnderka committed Sep 29, 2018
1 parent f5e1d6d commit 9f7a229
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/Highlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,6 @@ private function tokenize($source)
foreach ($tokens as $token) {
if (is_array($token)) {
switch ($token[0]) {
case T_INLINE_HTML:
$newType = self::TOKEN_HTML;
break;

case T_COMMENT:
case T_DOC_COMMENT:
$newType = self::TOKEN_COMMENT;
break;

case T_ENCAPSED_AND_WHITESPACE:
case T_CONSTANT_ENCAPSED_STRING:
$newType = self::TOKEN_STRING;
break;

case T_WHITESPACE:
break;

Expand All @@ -156,6 +142,20 @@ private function tokenize($source)
$newType = self::TOKEN_DEFAULT;
break;

case T_COMMENT:
case T_DOC_COMMENT:
$newType = self::TOKEN_COMMENT;
break;

case T_ENCAPSED_AND_WHITESPACE:
case T_CONSTANT_ENCAPSED_STRING:
$newType = self::TOKEN_STRING;
break;

case T_INLINE_HTML:
$newType = self::TOKEN_HTML;
break;

default:
$newType = self::TOKEN_KEYWORD;
}
Expand All @@ -167,7 +167,7 @@ private function tokenize($source)
$currentType = $newType;
}

if ($currentType != $newType) {
if ($currentType !== $newType) {
$output[] = array($currentType, $buffer);
$buffer = '';
$currentType = $newType;
Expand Down

0 comments on commit 9f7a229

Please sign in to comment.