refactor(ratecontroller): Simplify delta_stat logic

This commit is contained in:
Nils Andreas Svee committed 2026-02-21 22:42:20 +07:00
1 parent 67bb185e28
commit 2aec477b89
1 file changed
+2 -7
+2 -7
View File
@@ -151,10 +151,7 @@ impl Ratecontroller {
if !state.deltas.is_empty() {
state.next_rate = state.current_rate;
if state.deltas.len() < 3 {
state.next_rate = min_rate;
} else {
state.delta_stat = if state.deltas[2] > 0.0 {
state.delta_stat = if state.deltas.len() >= 3 {
state.deltas[2]
} else {
state.deltas[0]
@@ -171,8 +168,7 @@ impl Ratecontroller {
/ dur.as_secs_f64();
state.load = state.utilisation / state.current_rate;
if state.delta_stat > 0.0
&& state.delta_stat < delay_ms
if state.delta_stat < delay_ms
&& state.load > self.config.high_load_level
{
state.safe_rates[state.nrate] = (state.current_rate * state.load).round();
@@ -202,7 +198,6 @@ impl Ratecontroller {
}
}
}
}
state.next_rate = state.next_rate.max(min_rate).round();
state.previous_bytes = state.current_bytes;