Skip to content

Commit 79fc56e

Browse files
committed
TrinaryLogic: faster or()
1 parent 6f52f85 commit 79fc56e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/TrinaryLogic.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,15 @@ public function lazyAnd(
119119

120120
public function or(self ...$operands): self
121121
{
122-
$operandValues = array_column($operands, 'value');
123-
$operandValues[] = $this->value;
124-
return self::create(max($operandValues));
122+
$max = $this->value;
123+
foreach ($operands as $operand) {
124+
if ($operand->value < $max) {
125+
continue;
126+
}
127+
128+
$max = $operand->value;
129+
}
130+
return self::create($max);
125131
}
126132

127133
/**

0 commit comments

Comments
 (0)