From 7a4937bbccab9a9bd8f344e347fee908781f5e15 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Tue, 10 Jul 2018 18:24:06 +0200 Subject: [PATCH] Specialize Rule2Literal->equals(Rule2Literal) for speedup --- src/Composer/DependencyResolver/Rule2Literals.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Composer/DependencyResolver/Rule2Literals.php b/src/Composer/DependencyResolver/Rule2Literals.php index c44a15ab2..c2d95f483 100644 --- a/src/Composer/DependencyResolver/Rule2Literals.php +++ b/src/Composer/DependencyResolver/Rule2Literals.php @@ -65,6 +65,19 @@ class Rule2Literals extends Rule */ public function equals(Rule $rule) { + // specialized fast-case + if ($rule instanceof self) { + if ($this->literal1 !== $rule->literal1) { + return false; + } + + if ($this->literal2 !== $rule->literal2) { + return false; + } + + return true; + } + $literals = $rule->getLiterals(); if (2 != count($literals)) { return false;