Make ruleById lookup table in rule set public
Saves about 500k function calls on a packagist updatepull/3481/head
parent
5c0efdcaa2
commit
d77400ade2
|
@ -22,6 +22,13 @@ class RuleSet implements \IteratorAggregate, \Countable
|
|||
const TYPE_JOB = 1;
|
||||
const TYPE_LEARNED = 4;
|
||||
|
||||
/**
|
||||
* Lookup table for rule id to rule object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $ruleById;
|
||||
|
||||
protected static $types = array(
|
||||
-1 => 'UNKNOWN',
|
||||
self::TYPE_PACKAGE => 'PACKAGE',
|
||||
|
@ -30,7 +37,6 @@ class RuleSet implements \IteratorAggregate, \Countable
|
|||
);
|
||||
|
||||
protected $rules;
|
||||
protected $ruleById;
|
||||
protected $nextRuleId;
|
||||
|
||||
protected $rulesByHash;
|
||||
|
@ -76,11 +82,6 @@ class RuleSet implements \IteratorAggregate, \Countable
|
|||
return $this->nextRuleId;
|
||||
}
|
||||
|
||||
public function ruleById($id)
|
||||
{
|
||||
return $this->ruleById[$id];
|
||||
}
|
||||
|
||||
public function getRules()
|
||||
{
|
||||
return $this->rules;
|
||||
|
|
|
@ -56,7 +56,7 @@ class Solver
|
|||
|
||||
$rulesCount = count($this->rules);
|
||||
for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
|
||||
$rule = $this->rules->ruleById($ruleIndex);
|
||||
$rule = $this->rules->ruleById[$ruleIndex];
|
||||
|
||||
if (!$rule->isAssertion() || $rule->isDisabled()) {
|
||||
continue;
|
||||
|
@ -687,7 +687,7 @@ class Solver
|
|||
$i = 0;
|
||||
}
|
||||
|
||||
$rule = $this->rules->ruleById($i);
|
||||
$rule = $this->rules->ruleById[$i];
|
||||
$literals = $rule->literals;
|
||||
|
||||
if ($rule->isDisabled()) {
|
||||
|
|
|
@ -76,7 +76,7 @@ class RuleSetTest extends TestCase
|
|||
$rule = new Rule($this->pool, array(), 'job1', null);
|
||||
$ruleSet->add($rule, RuleSet::TYPE_JOB);
|
||||
|
||||
$this->assertSame($rule, $ruleSet->ruleById(0));
|
||||
$this->assertSame($rule, $ruleSet->ruleById[0]);
|
||||
}
|
||||
|
||||
public function testGetIterator()
|
||||
|
|
Loading…
Reference in New Issue