Literals on rule are now public

This causes a reduction of ~500k function calls for packagist composer
update (~14 million total).
main
Nils Adermann 10 years ago
parent 5333017aea
commit ef41f136f8

@ -32,7 +32,6 @@ class Rule
protected $pool;
protected $disabled;
protected $literals;
protected $type;
protected $id;
protected $reason;
@ -42,6 +41,8 @@ class Rule
protected $ruleHash;
public $literals;
public function __construct(Pool $pool, array $literals, $reason, $reasonData, $job = null)
{
$this->pool = $pool;
@ -160,11 +161,6 @@ class Rule
return !$this->disabled;
}
public function getLiterals()
{
return $this->literals;
}
public function isAssertion()
{
return 1 === count($this->literals);

@ -95,7 +95,7 @@ class RuleWatchGraph
$otherWatch = $node->getOtherWatch($literal);
if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
$ruleLiterals = $node->getRule()->getLiterals();
$ruleLiterals = $node->getRule()->literals;
$alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
return $literal !== $ruleLiteral &&

@ -35,7 +35,7 @@ class RuleWatchNode
{
$this->rule = $rule;
$literals = $rule->getLiterals();
$literals = $rule->literals;
$this->watch1 = count($literals) > 0 ? $literals[0] : 0;
$this->watch2 = count($literals) > 1 ? $literals[1] : 0;
@ -51,7 +51,7 @@ class RuleWatchNode
*/
public function watch2OnHighest(Decisions $decisions)
{
$literals = $this->rule->getLiterals();
$literals = $this->rule->literals;
// if there are only 2 elements, both are being watched anyway
if (count($literals) < 3) {

@ -62,7 +62,7 @@ class Solver
continue;
}
$literals = $rule->getLiterals();
$literals = $rule->literals;
$literal = $literals[0];
if (!$this->decisions->decided(abs($literal))) {
@ -104,7 +104,7 @@ class Solver
continue;
}
$assertRuleLiterals = $assertRule->getLiterals();
$assertRuleLiterals = $assertRule->literals;
$assertRuleLiteral = $assertRuleLiterals[0];
if (abs($literal) !== abs($assertRuleLiteral)) {
@ -356,7 +356,7 @@ class Solver
while (true) {
$this->learnedPool[count($this->learnedPool) - 1][] = $rule;
foreach ($rule->getLiterals() as $literal) {
foreach ($rule->literals as $literal) {
// skip the one true literal
if ($this->decisions->satisfy($literal)) {
continue;
@ -480,7 +480,7 @@ class Solver
$this->problems[] = $problem;
$seen = array();
$literals = $conflictRule->getLiterals();
$literals = $conflictRule->literals;
foreach ($literals as $literal) {
// skip the one true literal
@ -503,7 +503,7 @@ class Solver
$problem->addRule($why);
$this->analyzeUnsolvableRule($problem, $why);
$literals = $why->getLiterals();
$literals = $why->literals;
foreach ($literals as $literal) {
// skip the one true literal
@ -627,7 +627,7 @@ class Solver
$decisionQueue = array();
$noneSatisfied = true;
foreach ($rule->getLiterals() as $literal) {
foreach ($rule->literals as $literal) {
if ($this->decisions->satisfy($literal)) {
$noneSatisfied = false;
break;
@ -688,7 +688,7 @@ class Solver
}
$rule = $this->rules->ruleById($i);
$literals = $rule->getLiterals();
$literals = $rule->literals;
if ($rule->isDisabled()) {
continue;

Loading…
Cancel
Save