Replace std::string::find() == 0 with absl::StartsWith (part 2).

This CL has been generated using clang-tidy [1] except for changes to
BUILD.gn files.

[1] - https://clang.llvm.org/extra/clang-tidy/checks/abseil-string-find-startswith.html

Bug: None
Change-Id: Ibf75601065a53bde28623b8eef57bec067235640
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172586
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30984}
This commit is contained in:
Mirko Bonadei 2020-04-01 13:43:08 +02:00 committed by Commit Bot
parent 55c991cc81
commit 06d3559b79
19 changed files with 52 additions and 35 deletions

View File

@ -149,6 +149,7 @@ rtc_library("rtc_software_fallback_wrappers") {
"../video:video_frame", "../video:video_frame",
"../video:video_rtp_headers", "../video:video_rtp_headers",
"//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
} }

View File

@ -17,6 +17,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "absl/strings/match.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/fec_controller_override.h" #include "api/fec_controller_override.h"
#include "api/video/i420_buffer.h" #include "api/video/i420_buffer.h"
@ -71,7 +72,7 @@ absl::optional<ForcedFallbackParams> ParseFallbackParamsFromFieldTrials(
const VideoEncoder& main_encoder) { const VideoEncoder& main_encoder) {
const std::string field_trial = const std::string field_trial =
webrtc::field_trial::FindFullName(kVp8ForceFallbackEncoderFieldTrial); webrtc::field_trial::FindFullName(kVp8ForceFallbackEncoderFieldTrial);
if (field_trial.find("Enabled") != 0) { if (!absl::StartsWith(field_trial, "Enabled")) {
return absl::nullopt; return absl::nullopt;
} }

View File

@ -13,6 +13,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/strings/match.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/transport/goog_cc_factory.h" #include "api/transport/goog_cc_factory.h"
#include "api/transport/network_types.h" #include "api/transport/network_types.h"
@ -60,7 +61,7 @@ TargetRateConstraints ConvertConstraints(const BitrateConstraints& contraints,
bool IsEnabled(const WebRtcKeyValueConfig* trials, absl::string_view key) { bool IsEnabled(const WebRtcKeyValueConfig* trials, absl::string_view key) {
RTC_DCHECK(trials != nullptr); RTC_DCHECK(trials != nullptr);
return trials->Lookup(key).find("Enabled") == 0; return absl::StartsWith(trials->Lookup(key), "Enabled");
} }
bool IsRelayed(const rtc::NetworkRoute& route) { bool IsRelayed(const rtc::NetworkRoute& route) {

View File

@ -58,6 +58,7 @@ rtc_library("pacing") {
"../rtp_rtcp:rtp_rtcp_format", "../rtp_rtcp:rtp_rtcp_format",
"../utility", "../utility",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
} }

View File

@ -15,6 +15,7 @@
#include <vector> #include <vector>
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/strings/match.h"
#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log.h"
#include "modules/utility/include/process_thread.h" #include "modules/utility/include/process_thread.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
@ -27,21 +28,19 @@ namespace webrtc {
const int64_t PacedSender::kMaxQueueLengthMs = 2000; const int64_t PacedSender::kMaxQueueLengthMs = 2000;
const float PacedSender::kDefaultPaceMultiplier = 2.5f; const float PacedSender::kDefaultPaceMultiplier = 2.5f;
PacedSender::PacedSender(Clock* clock, PacedSender::PacedSender(Clock* clock, PacketRouter* packet_router,
PacketRouter* packet_router,
RtcEventLog* event_log, RtcEventLog* event_log,
const WebRtcKeyValueConfig* field_trials, const WebRtcKeyValueConfig* field_trials,
ProcessThread* process_thread) ProcessThread* process_thread)
: process_mode_((field_trials != nullptr && : process_mode_(
field_trials->Lookup("WebRTC-Pacer-DynamicProcess") (field_trials != nullptr &&
.find("Enabled") == 0) absl::StartsWith(field_trials->Lookup("WebRTC-Pacer-DynamicProcess"),
"Enabled"))
? PacingController::ProcessMode::kDynamic ? PacingController::ProcessMode::kDynamic
: PacingController::ProcessMode::kPeriodic), : PacingController::ProcessMode::kPeriodic),
pacing_controller_(clock, pacing_controller_(clock,
static_cast<PacingController::PacketSender*>(this), static_cast<PacingController::PacketSender*>(this),
event_log, event_log, field_trials, process_mode_),
field_trials,
process_mode_),
clock_(clock), clock_(clock),
packet_router_(packet_router), packet_router_(packet_router),
process_thread_(process_thread) { process_thread_(process_thread) {

View File

@ -15,6 +15,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/strings/match.h"
#include "modules/pacing/bitrate_prober.h" #include "modules/pacing/bitrate_prober.h"
#include "modules/pacing/interval_budget.h" #include "modules/pacing/interval_budget.h"
#include "modules/utility/include/process_thread.h" #include "modules/utility/include/process_thread.h"
@ -42,12 +43,12 @@ constexpr int kFirstPriority = 0;
bool IsDisabled(const WebRtcKeyValueConfig& field_trials, bool IsDisabled(const WebRtcKeyValueConfig& field_trials,
absl::string_view key) { absl::string_view key) {
return field_trials.Lookup(key).find("Disabled") == 0; return absl::StartsWith(field_trials.Lookup(key), "Disabled");
} }
bool IsEnabled(const WebRtcKeyValueConfig& field_trials, bool IsEnabled(const WebRtcKeyValueConfig& field_trials,
absl::string_view key) { absl::string_view key) {
return field_trials.Lookup(key).find("Enabled") == 0; return absl::StartsWith(field_trials.Lookup(key), "Enabled");
} }
int GetPriorityForType(RtpPacketMediaType type) { int GetPriorityForType(RtpPacketMediaType type) {

View File

@ -14,6 +14,7 @@
#include <cstdint> #include <cstdint>
#include <utility> #include <utility>
#include "absl/strings/match.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
@ -105,7 +106,7 @@ bool IsEnabled(const WebRtcKeyValueConfig* field_trials, const char* name) {
if (!field_trials) { if (!field_trials) {
return false; return false;
} }
return field_trials->Lookup(name).find("Enabled") == 0; return absl::StartsWith(field_trials->Lookup(name), "Enabled");
} }
RoundRobinPacketQueue::RoundRobinPacketQueue( RoundRobinPacketQueue::RoundRobinPacketQueue(

View File

@ -59,6 +59,7 @@ rtc_library("remote_bitrate_estimator") {
"../../system_wrappers", "../../system_wrappers",
"../../system_wrappers:field_trial", "../../system_wrappers:field_trial",
"../../system_wrappers:metrics", "../../system_wrappers:metrics",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
} }

View File

@ -18,6 +18,7 @@
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include "absl/strings/match.h"
#include "api/transport/network_types.h" #include "api/transport/network_types.h"
#include "api/units/data_rate.h" #include "api/units/data_rate.h"
#include "modules/remote_bitrate_estimator/include/bwe_defines.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h"
@ -37,12 +38,12 @@ constexpr char kBweBackOffFactorExperiment[] = "WebRTC-BweBackOffFactor";
bool IsEnabled(const WebRtcKeyValueConfig& field_trials, bool IsEnabled(const WebRtcKeyValueConfig& field_trials,
absl::string_view key) { absl::string_view key) {
return field_trials.Lookup(key).find("Enabled") == 0; return absl::StartsWith(field_trials.Lookup(key), "Enabled");
} }
bool IsNotDisabled(const WebRtcKeyValueConfig& field_trials, bool IsNotDisabled(const WebRtcKeyValueConfig& field_trials,
absl::string_view key) { absl::string_view key) {
return field_trials.Lookup(key).find("Disabled") != 0; return !absl::StartsWith(field_trials.Lookup(key), "Disabled");
} }
double ReadBackoffFactor(const WebRtcKeyValueConfig& key_value_config) { double ReadBackoffFactor(const WebRtcKeyValueConfig& key_value_config) {

View File

@ -148,20 +148,19 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
packetization_overhead_bitrate_(1000, RateStatistics::kBpsScale), packetization_overhead_bitrate_(1000, RateStatistics::kBpsScale),
frame_encryptor_(config.frame_encryptor), frame_encryptor_(config.frame_encryptor),
require_frame_encryption_(config.require_frame_encryption), require_frame_encryption_(config.require_frame_encryption),
generic_descriptor_auth_experiment_( generic_descriptor_auth_experiment_(!absl::StartsWith(
config.field_trials->Lookup("WebRTC-GenericDescriptorAuth") config.field_trials->Lookup("WebRTC-GenericDescriptorAuth"),
.find("Disabled") != 0), "Disabled")),
exclude_transport_sequence_number_from_fec_experiment_( exclude_transport_sequence_number_from_fec_experiment_(absl::StartsWith(
config.field_trials config.field_trials->Lookup(
->Lookup(kExcludeTransportSequenceNumberFromFecFieldTrial) kExcludeTransportSequenceNumberFromFecFieldTrial),
.find("Enabled") == 0), "Enabled")),
absolute_capture_time_sender_(config.clock), absolute_capture_time_sender_(config.clock),
frame_transformer_delegate_( frame_transformer_delegate_(
config.frame_transformer config.frame_transformer
? new rtc::RefCountedObject< ? new rtc::RefCountedObject<
RTPSenderVideoFrameTransformerDelegate>( RTPSenderVideoFrameTransformerDelegate>(
this, this, std::move(config.frame_transformer))
std::move(config.frame_transformer))
: nullptr) { : nullptr) {
if (frame_transformer_delegate_) if (frame_transformer_delegate_)
frame_transformer_delegate_->Init(); frame_transformer_delegate_->Init();

View File

@ -164,6 +164,7 @@ rtc_library("rate_control_settings") {
"../../api/units:data_size", "../../api/units:data_size",
"../../api/video_codecs:video_codecs_api", "../../api/video_codecs:video_codecs_api",
"../../system_wrappers:field_trial", "../../system_wrappers:field_trial",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
} }

View File

@ -15,6 +15,7 @@
#include <string> #include <string>
#include "absl/strings/match.h"
#include "api/transport/field_trial_based_config.h" #include "api/transport/field_trial_based_config.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_conversions.h"
@ -42,7 +43,7 @@ const char* kScreenshareHysteresisFieldTrialname =
bool IsEnabled(const WebRtcKeyValueConfig* const key_value_config, bool IsEnabled(const WebRtcKeyValueConfig* const key_value_config,
absl::string_view key) { absl::string_view key) {
return key_value_config->Lookup(key).find("Enabled") == 0; return absl::StartsWith(key_value_config->Lookup(key), "Enabled");
} }
void ParseHysteresisFactor(const WebRtcKeyValueConfig* const key_value_config, void ParseHysteresisFactor(const WebRtcKeyValueConfig* const key_value_config,

View File

@ -15,6 +15,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "absl/strings/match.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/net_helpers.h" #include "rtc_base/net_helpers.h"
#include "rtc_base/network_monitor.h" #include "rtc_base/network_monitor.h"
@ -47,10 +48,10 @@ class FakeNetworkMonitor : public NetworkMonitorBase {
AdapterType GetAdapterType(const std::string& if_name) override { AdapterType GetAdapterType(const std::string& if_name) override {
// Note that the name matching rules are different from the // Note that the name matching rules are different from the
// GetAdapterTypeFromName in NetworkManager. // GetAdapterTypeFromName in NetworkManager.
if (if_name.find("wifi") == 0) { if (absl::StartsWith(if_name, "wifi")) {
return ADAPTER_TYPE_WIFI; return ADAPTER_TYPE_WIFI;
} }
if (if_name.find("cellular") == 0) { if (absl::StartsWith(if_name, "cellular")) {
return ADAPTER_TYPE_CELLULAR; return ADAPTER_TYPE_CELLULAR;
} }
return ADAPTER_TYPE_UNKNOWN; return ADAPTER_TYPE_UNKNOWN;

View File

@ -128,6 +128,7 @@ rtc_library("video_test_common") {
"../rtc_base:timeutils", "../rtc_base:timeutils",
"../rtc_base/task_utils:repeating_task", "../rtc_base/task_utils:repeating_task",
"../system_wrappers", "../system_wrappers",
"//third_party/abseil-cpp/absl/strings",
] ]
} }

View File

@ -17,6 +17,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/strings/match.h"
#include "api/test/create_frame_generator.h" #include "api/test/create_frame_generator.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/critical_section.h" #include "rtc_base/critical_section.h"
@ -34,7 +35,7 @@ std::string TransformFilePath(std::string path) {
int ext_pos = path.rfind("."); int ext_pos = path.rfind(".");
if (ext_pos < 0) { if (ext_pos < 0) {
return test::ResourcePath(path, "yuv"); return test::ResourcePath(path, "yuv");
} else if (path.find(resource_prefix) == 0) { } else if (absl::StartsWith(path, resource_prefix)) {
std::string name = path.substr(resource_prefix.length(), ext_pos); std::string name = path.substr(resource_prefix.length(), ext_pos);
std::string ext = path.substr(ext_pos, path.size()); std::string ext = path.substr(ext_pos, path.size());
return test::ResourcePath(name, ext); return test::ResourcePath(name, ext);

View File

@ -144,6 +144,7 @@ if (rtc_include_tests) {
"//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
if (is_android) { if (is_android) {

View File

@ -13,6 +13,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/strings/match.h"
#include "api/test/create_frame_generator.h" #include "api/test/create_frame_generator.h"
#include "api/test/frame_generator_interface.h" #include "api/test/frame_generator_interface.h"
#include "api/test/video/function_video_encoder_factory.h" #include "api/test/video/function_video_encoder_factory.h"
@ -112,7 +113,7 @@ std::string TransformFilePath(std::string path) {
int ext_pos = path.rfind("."); int ext_pos = path.rfind(".");
if (ext_pos < 0) { if (ext_pos < 0) {
return test::ResourcePath(path, "yuv"); return test::ResourcePath(path, "yuv");
} else if (path.find(resource_prefix) == 0) { } else if (absl::StartsWith(path, resource_prefix)) {
std::string name = path.substr(resource_prefix.length(), ext_pos); std::string name = path.substr(resource_prefix.length(), ext_pos);
std::string ext = path.substr(ext_pos, path.size()); std::string ext = path.substr(ext_pos, path.size());
return test::ResourcePath(name, ext); return test::ResourcePath(name, ext);

View File

@ -124,6 +124,7 @@ rtc_library("video") {
"//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]

View File

@ -16,6 +16,7 @@
#include <limits> #include <limits>
#include <utility> #include <utility>
#include "absl/strings/match.h"
#include "api/video/video_codec_constants.h" #include "api/video/video_codec_constants.h"
#include "api/video/video_codec_type.h" #include "api/video/video_codec_type.h"
#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_codec.h"
@ -112,14 +113,16 @@ absl::optional<int> GetFallbackMaxPixels(const std::string& group) {
absl::optional<int> GetFallbackMaxPixelsIfFieldTrialEnabled() { absl::optional<int> GetFallbackMaxPixelsIfFieldTrialEnabled() {
std::string group = std::string group =
webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial); webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial);
return (group.find("Enabled") == 0) ? GetFallbackMaxPixels(group.substr(7)) return (absl::StartsWith(group, "Enabled"))
? GetFallbackMaxPixels(group.substr(7))
: absl::optional<int>(); : absl::optional<int>();
} }
absl::optional<int> GetFallbackMaxPixelsIfFieldTrialDisabled() { absl::optional<int> GetFallbackMaxPixelsIfFieldTrialDisabled() {
std::string group = std::string group =
webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial); webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial);
return (group.find("Disabled") == 0) ? GetFallbackMaxPixels(group.substr(8)) return (absl::StartsWith(group, "Disabled"))
? GetFallbackMaxPixels(group.substr(8))
: absl::optional<int>(); : absl::optional<int>();
} }
} // namespace } // namespace