Generate literal ids only once and use in equals()
Significant speedup because equals and getId() are called so frequently.pull/122/head
parent
4140f08d9c
commit
69f55d37bb
|
@ -25,6 +25,7 @@ class Literal
|
||||||
{
|
{
|
||||||
$this->package = $package;
|
$this->package = $package;
|
||||||
$this->wanted = $wanted;
|
$this->wanted = $wanted;
|
||||||
|
$this->id = ($this->wanted ? '' : '-') . $this->package->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWanted()
|
public function isWanted()
|
||||||
|
@ -44,7 +45,7 @@ class Literal
|
||||||
|
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
return ($this->wanted ? '' : '-') . $this->package->getId();
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
|
@ -59,6 +60,6 @@ class Literal
|
||||||
|
|
||||||
public function equals(Literal $b)
|
public function equals(Literal $b)
|
||||||
{
|
{
|
||||||
return $this->getId() === $b->getId();
|
return $this->id === $b->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue