From 21a0ae9cad2c75fa708ce9c0ffaaff9bf780579a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 14 Oct 2012 16:34:17 +0200 Subject: [PATCH] Cache whatProvide calls --- src/Composer/DependencyResolver/Pool.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index fd34897f2..381d5ba93 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -46,6 +46,7 @@ class Pool protected $acceptableStabilities; protected $stabilityFlags; protected $versionParser; + protected $providerCache = array(); protected $id = 1; public function __construct($minimumStability = 'stable', array $stabilityFlags = array()) @@ -215,6 +216,18 @@ class Pool * @return array A set of packages */ public function whatProvides($name, LinkConstraintInterface $constraint = null) + { + if (isset($this->providerCache[$name][(string) $constraint])) { + return $this->providerCache[$name][(string) $constraint]; + } + + return $this->providerCache[$name][(string) $constraint] = $this->computeWhatProvides($name, $constraint); + } + + /** + * @see whatProvides + */ + private function computeWhatProvides($name, $constraint) { $candidates = array();