Skip to content

Commit

Permalink
reduce semver version comparison complixity
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Davies <ben.davies@gmail.com>
  • Loading branch information
bendavies committed Feb 25, 2021
1 parent f90d55d commit 3f18927
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/Git/Value/SemVerVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ public function lessThanEqual(self $other): bool

private function compare(self $other): int
{
$comparison = $this->major <=> $other->major;

if ($comparison !== 0) {
return $comparison;
}

$comparison = $this->minor <=> $other->minor;

return $comparison !== 0 ? $comparison : $this->patch <=> $other->patch;
return [$this->major, $this->minor, $this->patch] <=> [$other->major, $other->minor, $other->patch];
}
}

0 comments on commit 3f18927

Please sign in to comment.