Skip to content

Commit 4e903ed

Browse files
kazutakahirataaokblast
authored andcommitted
[Analysis] Use std::clamp in getHeatColor (NFC) (llvm#165394)
This patch uses std::clamp to simplify manual clamping in getHeatColor.
1 parent 790b776 commit 4e903ed

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

llvm/lib/Analysis/HeatUtils.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,7 @@ std::string llvm::getHeatColor(uint64_t Freq, uint64_t MaxFreq) {
6464
}
6565

6666
std::string llvm::getHeatColor(double Percent) {
67-
if (Percent > 1.0)
68-
Percent = 1.0;
69-
if (Percent < 0.0)
70-
Percent = 0.0;
67+
Percent = std::clamp(Percent, 0.0, 1.0);
7168
unsigned ColorID = unsigned(round(Percent * (HeatSize - 1.0)));
7269
return HeatPalette[ColorID];
7370
}

0 commit comments

Comments
 (0)