10000 [ClassLoader] made a big performance improvement · brki/symfony@fb4f378 · GitHub
[go: up one dir, main page]

Skip to content

Commit fb4f378

Browse files
committed
[ClassLoader] made a big performance improvement
1 parent 627a7f7 commit fb4f378

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ static public function fixNamespaceDeclarations($source)
135135< 8000 div class="diff-text-inner"> $inNamespace = false;
136136
$tokens = token_get_all($source);
137137

138-
while ($token = array_shift($tokens)) {
138+
for ($i = 0, $max = count($tokens); $i < $max; $i++) {
139+
$token = $tokens[$i];
139140
if (is_string($token)) {
140141
$output .= $token;
141142
} elseif (T_NAMESPACE === $token[0]) {
@@ -145,12 +146,12 @@ static public function fixNamespaceDeclarations($source)
145146
$output .= $token[1];
146147

147148
// namespace name and whitespaces
148-
while (($t = array_shift($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
149+
while (($t = $tokens[++$i]) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
149150
$output .= $t[1];
150151
}
151152
if (is_string($t) && '{' === $t) {
152153
$inNamespace = false;
153-
array_unshift($tokens, $t);
154+
--$i;
154155
} else {
155156
$output .= "\n{";
156157
$inNamespace = true;

0 commit comments

Comments
 (0)
0