From 6510ee5c4c55b33e943393d7727eae37c457e010 Mon Sep 17 00:00:00 2001 From: Joe Holdcroft Date: Wed, 14 Nov 2012 11:41:08 +0000 Subject: [PATCH] Refactoring ClassLoader::add() to return early --- src/Composer/Autoload/ClassLoader.php | 29 ++++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index af2bdf933..1b4823742 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -90,21 +90,22 @@ class ClassLoader return; } - if (isset($this->prefixes[$prefix])) { - if ($prepend) { - $this->prefixes[$prefix] = array_merge( - (array) $paths, - $this->prefixes[$prefix] - ); - } - else { - $this->prefixes[$prefix] = array_merge( - $this->prefixes[$prefix], - (array) $paths - ); - } - } else { + if (!isset($this->prefixes[$prefix])) { $this->prefixes[$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixes[$prefix] = array_merge( + (array) $paths, + $this->prefixes[$prefix] + ); + } + else { + $this->prefixes[$prefix] = array_merge( + $this->prefixes[$prefix], + (array) $paths + ); } }