Browse Source

[ClassLoader] made another performance improvement

Fabien Potencier 14 years ago
parent
commit
968cc7532d
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

+ 5 - 2
src/Symfony/Component/ClassLoader/ClassCollectionLoader.php

@@ -97,7 +97,7 @@ class ClassCollectionLoader
 
             // 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);
@@ -110,7 +110,7 @@ class ClassCollectionLoader
         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
@@ -139,6 +139,9 @@ class ClassCollectionLoader
             $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";