Browse Source

Code optimizations: Avoiding counting repeatedly

Jordi Boggiano 12 năm trước cách đây
mục cha
commit
6a03e4f9ac
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      src/Composer/DependencyResolver/Solver.php

+ 2 - 1
src/Composer/DependencyResolver/Solver.php

@@ -53,7 +53,8 @@ class Solver
     {
         $decisionStart = count($this->decisions) - 1;
 
-        for ($ruleIndex = 0; $ruleIndex < count($this->rules); $ruleIndex++) {
+        $rulesCount = count($this->rules);
+        for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
             $rule = $this->rules->ruleById($ruleIndex);
 
             if (!$rule->isAssertion() || $rule->isDisabled()) {