diff options
author | Mirko Bonadei <mbonadei@webrtc.org> | 2020-04-01 12:03:11 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-01 11:15:00 +0000 |
commit | 57cabed0b08c9b5aba51610c1aea9bd8bccd45b1 (patch) | |
tree | 94e605ccbd371fa447fa82d7d7f4a2173f717655 /modules/congestion_controller | |
parent | e283d1ca64c61cb5fa7fce1bcb2cb5fdc067f103 (diff) | |
download | webrtc-57cabed0b08c9b5aba51610c1aea9bd8bccd45b1.tar.gz |
Replace std::string::find() == 0 with absl::StartsWith.
Bug: None
Change-Id: I070c4a5d19455f3a5c5d3ccc05f418545c351987
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172584
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30960}
Diffstat (limited to 'modules/congestion_controller')
7 files changed, 30 insertions, 16 deletions
diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 7ec13afc17..90af511451 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -51,6 +51,7 @@ rtc_library("goog_cc") { "../../../rtc_base/experiments:rate_control_settings", "../../../system_wrappers", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -78,6 +79,7 @@ rtc_library("pushback_controller") { "../../../api/units:data_size", "../../../rtc_base:checks", "../../../rtc_base/experiments:rate_control_settings", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -137,6 +139,7 @@ rtc_library("estimators") { "../../../rtc_base:safe_minmax", "../../../rtc_base/experiments:field_trial_parser", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -162,6 +165,7 @@ rtc_library("loss_based_controller") { "../../../system_wrappers:field_trial", "../../../system_wrappers:metrics", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -187,6 +191,7 @@ rtc_library("delay_based_bwe") { "../../../system_wrappers:metrics", "../../pacing", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -213,6 +218,7 @@ rtc_library("probe_controller") { "../../../rtc_base/experiments:field_trial_parser", "../../../rtc_base/system:unused", "../../../system_wrappers:metrics", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc index 479fefc565..ec642823df 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc @@ -16,6 +16,7 @@ #include <algorithm> #include <string> +#include "absl/strings/match.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/rate_control_settings.h" @@ -24,8 +25,9 @@ namespace webrtc { CongestionWindowPushbackController::CongestionWindowPushbackController( const WebRtcKeyValueConfig* key_value_config) : add_pacing_( - key_value_config->Lookup("WebRTC-AddPacingToCongestionWindowPushback") - .find("Enabled") == 0), + absl::StartsWith(key_value_config->Lookup( + "WebRTC-AddPacingToCongestionWindowPushback"), + "Enabled")), min_pushback_target_bitrate_bps_( RateControlSettings::ParseFromKeyValueConfig(key_value_config) .CongestionWindowMinPushbackTargetBitrateBps()), diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.cc b/modules/congestion_controller/goog_cc/delay_based_bwe.cc index 33995ff2b5..1c02301284 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.cc @@ -17,6 +17,7 @@ #include <string> #include <utility> +#include "absl/strings/match.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h" @@ -113,9 +114,9 @@ DelayBasedBwe::DelayBasedBwe(const WebRtcKeyValueConfig* key_value_config, prev_bitrate_(DataRate::Zero()), has_once_detected_overuse_(false), prev_state_(BandwidthUsage::kBwNormal), - alr_limited_backoff_enabled_( - key_value_config->Lookup("WebRTC-Bwe-AlrLimitedBackoff") - .find("Enabled") == 0) { + alr_limited_backoff_enabled_(absl::StartsWith( + key_value_config->Lookup("WebRTC-Bwe-AlrLimitedBackoff"), + "Enabled")) { RTC_LOG(LS_INFO) << "Initialized DelayBasedBwe with small packet filtering " << ignore_small_.Parser()->Encode() << ", separate audio overuse detection" diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index 10e775b254..e29a6704ba 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -21,6 +21,7 @@ #include <utility> #include <vector> +#include "absl/strings/match.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/events/rtc_event_remote_estimate.h" #include "modules/congestion_controller/goog_cc/alr_detector.h" @@ -53,11 +54,11 @@ int64_t GetBpsOrDefault(const absl::optional<DataRate>& rate, } bool IsEnabled(const WebRtcKeyValueConfig* config, absl::string_view key) { - return config->Lookup(key).find("Enabled") == 0; + return absl::StartsWith(config->Lookup(key), "Enabled"); } bool IsNotDisabled(const WebRtcKeyValueConfig* config, absl::string_view key) { - return config->Lookup(key).find("Disabled") != 0; + return !absl::StartsWith(config->Lookup(key), "Disabled"); } } // namespace diff --git a/modules/congestion_controller/goog_cc/probe_controller.cc b/modules/congestion_controller/goog_cc/probe_controller.cc index c921bd9001..29b472a873 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.cc +++ b/modules/congestion_controller/goog_cc/probe_controller.cc @@ -15,6 +15,7 @@ #include <memory> #include <string> +#include "absl/strings/match.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -129,12 +130,12 @@ ProbeControllerConfig::~ProbeControllerConfig() = default; ProbeController::ProbeController(const WebRtcKeyValueConfig* key_value_config, RtcEventLog* event_log) : enable_periodic_alr_probing_(false), - in_rapid_recovery_experiment_( - key_value_config->Lookup(kBweRapidRecoveryExperiment) - .find("Enabled") == 0), - limit_probes_with_allocateable_rate_( - key_value_config->Lookup(kCappedProbingFieldTrialName) - .find("Disabled") != 0), + in_rapid_recovery_experiment_(absl::StartsWith( + key_value_config->Lookup(kBweRapidRecoveryExperiment), + "Enabled")), + limit_probes_with_allocateable_rate_(!absl::StartsWith( + key_value_config->Lookup(kCappedProbingFieldTrialName), + "Disabled")), event_log_(event_log), config_(ProbeControllerConfig(key_value_config)) { Reset(0); diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc index 7ebef6c73a..d2ae528404 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -16,6 +16,7 @@ #include <memory> #include <string> +#include "absl/strings/match.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h" @@ -60,7 +61,7 @@ bool BweLossExperimentIsEnabled() { std::string experiment_string = webrtc::field_trial::FindFullName(kBweLosExperiment); // The experiment is enabled iff the field trial string begins with "Enabled". - return experiment_string.find("Enabled") == 0; + return absl::StartsWith(experiment_string, "Enabled"); } bool ReadBweLossExperimentParameters(float* low_loss_threshold, diff --git a/modules/congestion_controller/goog_cc/trendline_estimator.cc b/modules/congestion_controller/goog_cc/trendline_estimator.cc index 6675a3b0e9..c04db7351d 100644 --- a/modules/congestion_controller/goog_cc/trendline_estimator.cc +++ b/modules/congestion_controller/goog_cc/trendline_estimator.cc @@ -15,6 +15,7 @@ #include <algorithm> #include <string> +#include "absl/strings/match.h" #include "absl/types/optional.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h" #include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" @@ -115,8 +116,9 @@ constexpr char TrendlineEstimatorSettings::kKey[]; TrendlineEstimatorSettings::TrendlineEstimatorSettings( const WebRtcKeyValueConfig* key_value_config) { - if (key_value_config->Lookup(kBweWindowSizeInPacketsExperiment) - .find("Enabled") == 0) { + if (absl::StartsWith( + key_value_config->Lookup(kBweWindowSizeInPacketsExperiment), + "Enabled")) { window_size = ReadTrendlineFilterWindowSize(key_value_config); } Parser()->Parse(key_value_config->Lookup(TrendlineEstimatorSettings::kKey)); |