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}
diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn
index 7ec13af..90af511 100644
--- a/modules/congestion_controller/goog_cc/BUILD.gn
+++ b/modules/congestion_controller/goog_cc/BUILD.gn
@@ -51,6 +51,7 @@
"../../../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 @@
"../../../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_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 @@
"../../../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 @@
"../../../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_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 479fefc..ec64282 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 @@
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 33995ff..1c02301 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 @@
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 10e775b..e29a670 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 @@
}
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 c921bd9..29b472a8 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 @@
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 7ebef6c7..d2ae528 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 @@
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 6675a3b..c04db73 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 @@
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));
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index 4341ce1..576685c 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -360,6 +360,7 @@
"../test:test_support",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory",
+ "//third_party/abseil-cpp/absl/strings",
]
if (rtc_build_libsrtp) {
diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc
index ffc4a6f..1a4b507 100644
--- a/pc/media_session_unittest.cc
+++ b/pc/media_session_unittest.cc
@@ -18,6 +18,7 @@
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
+#include "absl/strings/match.h"
#include "media/base/codec.h"
#include "media/base/test_utils.h"
#include "media/sctp/sctp_transport_internal.h"
@@ -3061,7 +3062,7 @@
VideoContentDescription* desc = media_desc->as_video();
std::vector<VideoCodec> codecs = desc->codecs();
for (VideoCodec& codec : codecs) {
- if (codec.name.find(cricket::kRtxCodecName) == 0) {
+ if (absl::StartsWith(codec.name, cricket::kRtxCodecName)) {
codec.params.clear();
}
}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 27cbedf..14281eb 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -5820,8 +5820,9 @@
// by experiment.
if (configuration.disable_ipv6) {
port_allocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6);
- } else if (webrtc::field_trial::FindFullName("WebRTC-IPv6Default")
- .find("Disabled") == 0) {
+ } else if (absl::StartsWith(
+ webrtc::field_trial::FindFullName("WebRTC-IPv6Default"),
+ "Disabled")) {
port_allocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6);
}
diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc
index cfb8718..9a758be 100644
--- a/pc/peer_connection_factory.cc
+++ b/pc/peer_connection_factory.cc
@@ -14,6 +14,7 @@
#include <utility>
#include <vector>
+#include "absl/strings/match.h"
#include "api/fec_controller.h"
#include "api/media_stream_proxy.h"
#include "api/media_stream_track_proxy.h"
@@ -397,7 +398,7 @@
bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const {
RTC_DCHECK(trials_);
- return trials_->Lookup(key).find("Enabled") == 0;
+ return absl::StartsWith(trials_->Lookup(key), "Enabled");
}
} // namespace webrtc
diff --git a/pc/srtp_filter.cc b/pc/srtp_filter.cc
index d4ad3bb..bd48eac 100644
--- a/pc/srtp_filter.cc
+++ b/pc/srtp_filter.cc
@@ -14,6 +14,7 @@
#include <cstdint>
+#include "absl/strings/match.h"
#include "rtc_base/logging.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/third_party/base64/base64.h"
@@ -257,7 +258,7 @@
// example key_params: "inline:YUJDZGVmZ2hpSktMbW9QUXJzVHVWd3l6MTIzNDU2"
// Fail if key-method is wrong.
- if (key_params.find("inline:") != 0) {
+ if (!absl::StartsWith(key_params, "inline:")) {
return false;
}
diff --git a/pc/srtp_transport.cc b/pc/srtp_transport.cc
index 6306d50..71a58d0 100644
--- a/pc/srtp_transport.cc
+++ b/pc/srtp_transport.cc
@@ -17,6 +17,7 @@
#include <utility>
#include <vector>
+#include "absl/strings/match.h"
#include "media/base/rtp_utils.h"
#include "pc/rtp_transport.h"
#include "pc/srtp_session.h"
@@ -493,7 +494,7 @@
// example key_params: "inline:YUJDZGVmZ2hpSktMbW9QUXJzVHVWd3l6MTIzNDU2"
// Fail if key-method is wrong.
- if (key_params.find("inline:") != 0) {
+ if (!absl::StartsWith(key_params, "inline:")) {
return false;
}