Skip to content

Commit

Permalink
[ClassLoader] made another performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 17, 2011
1 parent fb4f378 commit 968cc75
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
Expand Up @@ -97,7 +97,7 @@ static public function load($classes, $cacheDir, $name, $autoReload, $adaptive =

// add namespace declaration for global code
if (!$r->inNamespace()) {
$c = "\nnamespace\n{\n$c\n}\n";
$c = "\nnamespace\n{\n".self::stripComments($c)."\n}\n";
} else {
$c = self::fixNamespaceDeclarations('<?php '.$c);
$c = preg_replace('/^\s*<\?php/', '', $c);
Expand All @@ -110,7 +110,7 @@ static public function load($classes, $cacheDir, $name, $autoReload, $adaptive =
if (!is_dir(dirname($cache))) {
mkdir(dirname($cache), 0777, true);
}
self::writeCacheFile($cache, self::stripComments('<?php '.$content));
self::writeCacheFile($cache, '<?php '.$content);

if ($autoReload) {
// save the resources
Expand Down Expand Up @@ -139,6 +139,9 @@ static public function fixNamespaceDeclarations($source)
$token = $tokens[$i];
if (is_string($token)) {
$output .= $token;
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
// strip comments
continue;
} elseif (T_NAMESPACE === $token[0]) {
if ($inNamespace) {
$output .= "}\n";
Expand Down

0 comments on commit 968cc75

Please sign in to comment.