From 18f26d143411710fb64544246ecf0d30bc1d4e82 Mon Sep 17 00:00:00 2001 From: Oskar Sundbom Date: Thu, 16 Nov 2017 10:52:14 +0100 Subject: [PATCH] Optional: Use nullopt and implicit construction in /modules/remote_bitrate_estimator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes places where we explicitly construct an Optional to instead use nullopt or the requisite value type only. This CL was uploaded by git cl split. R=terelius@webrtc.org Bug: None Change-Id: I1d2538482e2390d91f3285124d011a578da4b61b Reviewed-on: https://webrtc-review.googlesource.com/23564 Reviewed-by: Björn Terelius Commit-Queue: Oskar Sundbom Cr-Commit-Position: refs/heads/master@{#20710} --- modules/remote_bitrate_estimator/aimd_rate_control.cc | 5 ++--- .../aimd_rate_control_unittest.cc | 3 +-- .../test/estimators/congestion_window_unittest.cc | 11 +++++------ 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/modules/remote_bitrate_estimator/aimd_rate_control.cc b/modules/remote_bitrate_estimator/aimd_rate_control.cc index b83a3c6993..288c3d71fe 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -250,10 +250,9 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps, // If bitrate decreases more than a normal back off after overuse, it // indicates a real network degradation. We do not let such a decrease // to determine the bandwidth estimation period. - last_decrease_ = rtc::Optional(); + last_decrease_ = rtc::nullopt; } else { - last_decrease_ = - rtc::Optional(current_bitrate_bps_ - new_bitrate_bps); + last_decrease_ = current_bitrate_bps_ - new_bitrate_bps; } } if (incoming_bitrate_kbps < diff --git a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc index 1e894d93d3..f6844b0e94 100644 --- a/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc +++ b/modules/remote_bitrate_estimator/aimd_rate_control_unittest.cc @@ -45,8 +45,7 @@ void UpdateRateControl(const AimdRateControlStates& states, const BandwidthUsage& bandwidth_usage, int bitrate, int64_t now_ms) { - RateControlInput input(bandwidth_usage, rtc::Optional(bitrate), - now_ms); + RateControlInput input(bandwidth_usage, bitrate, now_ms); states.aimd_rate_control->Update(&input, now_ms); } diff --git a/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc b/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc index 3f8760cac7..9b394b7b62 100644 --- a/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc +++ b/modules/remote_bitrate_estimator/test/estimators/congestion_window_unittest.cc @@ -45,18 +45,17 @@ TEST(CongestionWindowTest, DataInflight) { TEST(CongestionWindowTest, ZeroBandwidthDelayProduct) { CongestionWindow congestion_window; int64_t target_congestion_window = - congestion_window.GetTargetCongestionWindow( - 100, rtc::Optional(0), 2.885f); + congestion_window.GetTargetCongestionWindow(100, 0, 2.885f); EXPECT_EQ(target_congestion_window, 2.885f * kStartingCongestionWindow); } TEST(CongestionWindowTest, CalculateCongestionWindow) { CongestionWindow congestion_window; - int64_t cwnd = congestion_window.GetCongestionWindow( - BbrBweSender::STARTUP, 800000, rtc::Optional(100l), 2.885f); + int64_t cwnd = congestion_window.GetCongestionWindow(BbrBweSender::STARTUP, + 800000, 100l, 2.885f); EXPECT_EQ(cwnd, 28850); - cwnd = congestion_window.GetCongestionWindow( - BbrBweSender::STARTUP, 400000, rtc::Optional(200l), 2.885f); + cwnd = congestion_window.GetCongestionWindow(BbrBweSender::STARTUP, 400000, + 200l, 2.885f); EXPECT_EQ(cwnd, 28850); } } // namespace bwe