Skip to content

Commit faef8e0

Browse files
staabmondrejmirtes
authored andcommitted
Faster TrinaryLogic->and()
1 parent 69369f4 commit faef8e0

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
@@ -79,9 +79,15 @@ public function toBooleanType(): BooleanType
7979

8080
public function and(self ...$operands): self
8181
{
82-
$operandValues = array_column($operands, 'value');
83-
$operandValues[] = $this->value;
84-
return self::create(min($operandValues));
82+
$min = $this->value;
83+
foreach ($operands as $operand) {
84+
if ($operand->value >= $min) {
85+
continue;
86+
}
87+
88+
$min = $operand->value;
89+
}
90+
return self::create($min);
8591
}
8692

8793
/**

0 commit comments

Comments
 (0)