From 132f2a9d5d315dc86acf1a57dc33c3b6fc78e622 Mon Sep 17 00:00:00 2001 From: Sander Marechal Date: Sun, 31 Mar 2013 13:23:51 +0200 Subject: [PATCH] Cache getcwd() result --- src/Composer/Autoload/AutoloadGenerator.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 6a9bbf835..f7abfe1c2 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -46,12 +46,13 @@ class AutoloadGenerator $targetDir = $vendorPath.'/'.$targetDir; $filesystem->ensureDirectoryExists($targetDir); - $relVendorPath = $filesystem->findShortestPath(getcwd(), $vendorPath, true); + $cwd = getcwd(); + $relVendorPath = $filesystem->findShortestPath($cwd, $vendorPath, true); $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true); $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode); $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true); - $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, getcwd(), true); + $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $cwd, true); $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode); $namespacesFile = <<findShortestPathCode($targetDir, getcwd(), true); + $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $cwd, true); $targetDirLoader = << $path) { if ('' === $namespace || 0 === strpos($class, $namespace)) { - $path = '/'.$filesystem->findShortestPath(getcwd(), $path, true); + $path = '/'.$filesystem->findShortestPath($cwd, $path, true); if (!isset($classMap[$class])) { $classMap[$class] = '$baseDir . '.var_export($path, true).",\n"; } @@ -158,7 +159,7 @@ EOF; $autoloads['classmap'] = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($autoloads['classmap'])); foreach ($autoloads['classmap'] as $dir) { foreach (ClassMapGenerator::createMap($dir) as $class => $path) { - $path = $filesystem->findShortestPath(getcwd(), $path, true); + $path = $filesystem->findShortestPath($cwd, $path, true); if ($filesystem->isAbsolutePath($path)) { $classMap[$class] = var_export($path, true).",\n"; } else {