From 69f55d37bb88d03805ed6788531b21b15bd92d1f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 21 Nov 2011 15:58:06 +0100 Subject: [PATCH] Generate literal ids only once and use in equals() Significant speedup because equals and getId() are called so frequently. --- src/Composer/DependencyResolver/Literal.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Composer/DependencyResolver/Literal.php b/src/Composer/DependencyResolver/Literal.php index 39f0e4cc5..1870e9a71 100644 --- a/src/Composer/DependencyResolver/Literal.php +++ b/src/Composer/DependencyResolver/Literal.php @@ -25,6 +25,7 @@ class Literal { $this->package = $package; $this->wanted = $wanted; + $this->id = ($this->wanted ? '' : '-') . $this->package->getId(); } public function isWanted() @@ -44,7 +45,7 @@ class Literal public function getId() { - return ($this->wanted ? '' : '-') . $this->package->getId(); + return $this->id; } public function __toString() @@ -59,6 +60,6 @@ class Literal public function equals(Literal $b) { - return $this->getId() === $b->getId(); + return $this->id === $b->id; } }