Skip to content

Commit 4773c61

Browse files
committed
Avoid repeating implicit/explicit float conversions.
1 parent e538a8e commit 4773c61

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/chasers/chaser_check.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ void chaser_check::do_update(object_key channel, uint64_t speed,
269269
}
270270

271271
// Integer to floating point.
272-
speeds_[channel] = to_floating(speed);
272+
const auto fast = to_floating(speed);
273+
speeds_[channel] = fast;
273274

274275
// Three elements are required to measure deviation, don't drop below.
275276
const auto count = speeds_.size();
@@ -288,22 +289,22 @@ void chaser_check::do_update(object_key channel, uint64_t speed,
288289
}
289290

290291
const auto mean = sum / count;
291-
if (speed >= mean)
292+
if (fast >= mean)
292293
{
293294
handler(error::success);
294295
return;
295296
}
296297

297298
const auto variance = (sum_squares - (sum * sum) / count) / sub1(count);
298299
const auto sdev = std::sqrt(variance);
299-
const auto slow = (mean - speed) > (allowed_deviation_ * sdev);
300+
const auto slow = (mean - fast) > (allowed_deviation_ * sdev);
300301

301302
// Only speed < mean channels are logged.
302303
LOGV("Below average channel (" << count << ") rate ("
303304
<< to_kilobits_per_second(sum) << ") mean ("
304305
<< to_kilobits_per_second(mean) << ") sdev ("
305306
<< to_kilobits_per_second(sdev) << ") Kbps [" << (slow ? "*" : "")
306-
<< to_kilobits_per_second(to_floating(speed)) << "].");
307+
<< to_kilobits_per_second(fast) << "].");
307308

308309
if (slow)
309310
{

0 commit comments

Comments
 (0)