فهرست منبع

few optimisations for XliffFileLoader and XmlFileLoader

stealth35 13 سال پیش
والد
کامیت
8d50c162b9

+ 2 - 2
src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

@@ -326,10 +326,10 @@ class XmlFileLoader extends FileLoader
         $imports = '';
         foreach ($schemaLocations as $namespace => $location) {
             $parts = explode('/', $location);
-            if (preg_match('#^phar://#i', $location)) {
+            if (0 === stripos($location, 'phar://')) {
                 $tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
                 if ($tmpfile) {
-                    file_put_contents($tmpfile, file_get_contents($location));
+                    copy($location, $tmpfile);
                     $tmpfiles[] = $tmpfile;
                     $parts = explode('/', str_replace('\\', '/', $tmpfile));
                 }

+ 2 - 3
src/Symfony/Component/Translation/Loader/XliffFileLoader.php

@@ -58,11 +58,10 @@ class XliffFileLoader implements LoaderInterface
 
         $location = str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd';
         $parts = explode('/', $location);
-        if (preg_match('#^phar://#i', $location)) {
+        if (0 === stripos($location, 'phar://')) {
             $tmpfile = tempnam(sys_get_temp_dir(), 'sf2');
             if ($tmpfile) {
-                file_put_contents($tmpfile, file_get_contents($location));
-                $tmpfiles[] = $tmpfile;
+                copy($location, $tmpfile);
                 $parts = explode('/', str_replace('\\', '/', $tmpfile));
             }
         }