Skip to content

Commit 3bc8d5b

Browse files
authored
Avoid unnecessary HealthStatus comparison (#58176)
It's only necessary to check `currentValue == HealthStatus.Unhealthy` when `currentValue` changes. During the first iteration, it is known to be `Healthy`.
1 parent 38c1d3a commit 3bc8d5b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/HealthChecks/Abstractions/src/HealthReport.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ private static HealthStatus CalculateAggregateStatus(IEnumerable<HealthReportEnt
6666
if (currentValue > entry.Status)
6767
{
6868
currentValue = entry.Status;
69-
}
7069

71-
if (currentValue == HealthStatus.Unhealthy)
72-
{
73-
// Game over, man! Game over!
74-
// (We hit the worst possible status, so there's no need to keep iterating)
75-
return currentValue;
70+
if (currentValue == HealthStatus.Unhealthy)
71+
{
72+
// Game over, man! Game over!
73+
// (We hit the worst possible status, so there's no need to keep iterating)
74+
return currentValue;
75+
}
7676
}
7777
}
7878

0 commit comments

Comments
 (0)