perf(semantic): early return if excess is 0 in Stats::increase_by (#22616)

This commit is contained in:
camc314 authored and Cameron Clark committed 2026-05-21 08:45:57 +01:00
1 parent 42e448fa2b
commit 8ff867465a
1 file changed
+4
+4
View File
@@ -104,6 +104,10 @@ impl Stats {
/// e.g. to over-allocate by 20%, pass `0.2` as `excess`.
#[must_use]
pub fn increase_by(mut self, excess: f64) -> Self {
if excess == 0.0 {
return self;
}
let factor = excess + 1.0;
#[expect(clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_lossless)]
let increase = |n: u32| (n as f64 * factor) as u32;