Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e57b5ba

Browse files
Workaround for a clang-tidy warning in CPUSpeedTracker (#47024)
The newly rolled version of clang-tidy is warning about some accesses to std::optional values. The function does a has_value check before accessing the values, but the analyzer does not detect that.
1 parent 0def2ab commit e57b5ba

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎fml/cpu_affinity.cc‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ CPUSpeedTracker::CPUSpeedTracker(std::vector<CpuIndexAndSpeed> data)
4747
min_speed.value() == max_speed.value()) {
4848
return;
4949
}
50+
const int64_t max_speed_value = max_speed.value();
51+
const int64_t min_speed_value = min_speed.value();
5052

5153
for (const auto& data : cpu_speeds_) {
52-
if (data.speed == max_speed.value()) {
54+
if (data.speed == max_speed_value) {
5355
performance_.push_back(data.index);
5456
} else {
5557
not_performance_.push_back(data.index);
5658
}
57-
if (data.speed == min_speed.value()) {
59+
if (data.speed == min_speed_value) {
5860
efficiency_.push_back(data.index);
5961
}
6062
}

0 commit comments

Comments
 (0)