Skip to content

Commit

Permalink
make PrecedenceComparer.Compare slightly more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
WalkerCodeRanger committed Jun 12, 2022
1 parent da79618 commit f351bdc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Semver/Comparers/PrecedenceComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ public override int Compare(SemVersion x, SemVersion y)
comparison = x.Patch.CompareTo(y.Patch);
if (comparison != 0) return comparison;

var xPrereleaseIdentifiers = x.PrereleaseIdentifiers;
var yPrereleaseIdentifiers = y.PrereleaseIdentifiers;

// Release are higher precedence than prerelease
var xIsRelease = xPrereleaseIdentifiers.Count == 0;
var yIsRelease = yPrereleaseIdentifiers.Count == 0;
var xIsRelease = x.IsRelease;
var yIsRelease = y.IsRelease;
if (xIsRelease && yIsRelease) return 0;
if (xIsRelease) return 1;
if (yIsRelease) return -1;

var xPrereleaseIdentifiers = x.PrereleaseIdentifiers;
var yPrereleaseIdentifiers = y.PrereleaseIdentifiers;

var minLength = Math.Min(xPrereleaseIdentifiers.Count, yPrereleaseIdentifiers.Count);
for (int i = 0; i < minLength; i++)
{
Expand Down

0 comments on commit f351bdc

Please sign in to comment.