Skip to content

Commit ace61b8

Browse files
committed
Micro-optimisation on array access
Reduces accessing two dimensions array eight times to once.
1 parent 24fa232 commit ace61b8

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

CakePHP/Sniffs/Formatting/BlankLineBeforeReturnSniff.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,18 @@ public function process(File $phpcsFile, $stackPtr)
5656
$prevLineTokens = [];
5757

5858
while ($current >= 0 && $tokens[$current]['line'] >= $previousLine) {
59+
$currentTokenCode = $tokens[$current]['code'];
5960
if (
6061
$tokens[$current]['line'] == $previousLine
61-
&& $tokens[$current]['code'] !== T_WHITESPACE
62-
&& $tokens[$current]['code'] !== T_COMMENT
63-
&& $tokens[$current]['code'] !== T_DOC_COMMENT_OPEN_TAG
64-
&& $tokens[$current]['code'] !== T_DOC_COMMENT_TAG
65-
&& $tokens[$current]['code'] !== T_DOC_COMMENT_STRING
66-
&& $tokens[$current]['code'] !== T_DOC_COMMENT_CLOSE_TAG
67-
&& $tokens[$current]['code'] !== T_DOC_COMMENT_WHITESPACE
62+
&& $currentTokenCode !== T_WHITESPACE
63+
&& $currentTokenCode !== T_COMMENT
64+
&& $currentTokenCode !== T_DOC_COMMENT_OPEN_TAG
65+
&& $currentTokenCode !== T_DOC_COMMENT_TAG
66+
&& $currentTokenCode !== T_DOC_COMMENT_STRING
67+
&& $currentTokenCode !== T_DOC_COMMENT_CLOSE_TAG
68+
&& $currentTokenCode !== T_DOC_COMMENT_WHITESPACE
6869
) {
69-
$prevLineTokens[] = $tokens[$current]['code'];
70+
$prevLineTokens[] = $currentTokenCode;
7071
}
7172
$current--;
7273
}

0 commit comments

Comments
 (0)