Skip to content

Commit

Permalink
inline calls in TrinaryLogic to reduce method call overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
clxmstaab authored and staabm committed Jul 28, 2022
1 parent e36e22c commit 05dabe9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/TrinaryLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@ private function __construct(private int $value)

public static function createYes(): self
{
return self::create(self::YES);
return self::$registry[self::YES] ??= new self(self::YES);
}

public static function createNo(): self
{
return self::create(self::NO);
return self::$registry[self::NO] ??= new self(self::NO);
}

public static function createMaybe(): self
{
return self::create(self::MAYBE);
return self::$registry[self::MAYBE] ??= new self(self::MAYBE);
}

public static function createFromBoolean(bool $value): self
{
return self::create($value ? self::YES : self::NO);
$yesNo = $value ? self::YES : self::NO;
return self::$registry[$yesNo] ??= new self($yesNo);
}

private static function create(int $value): self
Expand Down

0 comments on commit 05dabe9

Please sign in to comment.