Skip to content

Commit

Permalink
Avoid unnecessary HealthStatus comparison (#58176)
Browse files Browse the repository at this point in the history
It's only necessary to check `currentValue == HealthStatus.Unhealthy` when `currentValue` changes. During the first iteration, it is known to be `Healthy`.
  • Loading branch information
drewnoakes authored Oct 3, 2024
1 parent 38c1d3a commit 3bc8d5b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/HealthChecks/Abstractions/src/HealthReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ private static HealthStatus CalculateAggregateStatus(IEnumerable<HealthReportEnt
if (currentValue > entry.Status)
{
currentValue = entry.Status;
}

if (currentValue == HealthStatus.Unhealthy)
{
// Game over, man! Game over!
// (We hit the worst possible status, so there's no need to keep iterating)
return currentValue;
if (currentValue == HealthStatus.Unhealthy)
{
// Game over, man! Game over!
// (We hit the worst possible status, so there's no need to keep iterating)
return currentValue;
}
}
}

Expand Down

0 comments on commit 3bc8d5b

Please sign in to comment.