From 8da9cf55e5ec8b9390e41bb9eee3484b67be7cc7 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 25 Feb 2022 09:27:50 +0100 Subject: [PATCH] bbr: avoid unwrapping another checked Option value --- quinn-proto/src/congestion/bbr/bw_estimation.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/quinn-proto/src/congestion/bbr/bw_estimation.rs b/quinn-proto/src/congestion/bbr/bw_estimation.rs index 852e9b2c0..95a9a2c15 100644 --- a/quinn-proto/src/congestion/bbr/bw_estimation.rs +++ b/quinn-proto/src/congestion/bbr/bw_estimation.rs @@ -80,14 +80,13 @@ impl BandwidthEstimation { u64::MAX // will take the min of send and ack, so this is just a skip }; - let ack_rate = if self.prev_acked_time.is_none() { - 0 - } else { - BandwidthEstimation::bw_from_delta( + let ack_rate = match self.prev_acked_time { + Some(prev_acked_time) => BandwidthEstimation::bw_from_delta( self.total_acked - self.prev_total_acked, - now - self.prev_acked_time.unwrap(), + now - prev_acked_time, ) - .unwrap_or(0) + .unwrap_or(0), + None => 0, }; let bandwidth = send_rate.min(ack_rate);