[clang-tidy] Apply performance-faster-string-find fixes.

This CL applies clang-tidy's performance-faster-string-find [1] on the
WebRTC codebase.

All changes in this CL are automatically generated by both clang-tidy
and 'git cl format'.

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

Bug: webrtc:10252
Change-Id: I4b8c0396836f3c325488e37d97037fa04742a5d2
Reviewed-on: https://webrtc-review.googlesource.com/c/120047
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26423}
This commit is contained in:
Mirko Bonadei 2019-01-28 11:43:52 +01:00 committed by Commit Bot
parent 190713c7cd
commit 37ec55e2bb
5 changed files with 8 additions and 8 deletions

View File

@ -92,7 +92,7 @@ bool ParseArgsAndSetupEstimator(int argc,
fprintf(stderr, "0x%08x, ", s);
}
fprintf(stderr, "\n");
if (filename.substr(filename.find_last_of(".")) == ".pcap") {
if (filename.substr(filename.find_last_of('.')) == ".pcap") {
fprintf(stderr, "Opening as pcap\n");
*rtp_reader = webrtc::test::RtpFileReader::Create(
webrtc::test::RtpFileReader::kPcap, filename.c_str(),

View File

@ -706,7 +706,7 @@ bool Port::ParseStunUsername(const StunMessage* stun_msg,
// RFRAG:LFRAG
const std::string username = username_attr->GetString();
size_t colon_pos = username.find(":");
size_t colon_pos = username.find(':');
if (colon_pos == std::string::npos) {
return false;
}

View File

@ -2385,7 +2385,7 @@ TEST_F(WebRtcSdpTest, SerializeSessionDescriptionWithH264) {
std::string to_find = "a=fmtp:" + pt + " ";
size_t fmtp_pos = message.find(to_find);
ASSERT_NE(std::string::npos, fmtp_pos) << "Failed to find " << to_find;
size_t fmtp_endpos = message.find("\n", fmtp_pos);
size_t fmtp_endpos = message.find('\n', fmtp_pos);
ASSERT_NE(std::string::npos, fmtp_endpos);
std::string fmtp_value = message.substr(fmtp_pos, fmtp_endpos);
EXPECT_NE(std::string::npos, fmtp_value.find("level-asymmetry-allowed=1"));

View File

@ -174,7 +174,7 @@ bool SSLIdentity::PemToDer(const std::string& pem_type,
if (header == std::string::npos) {
return false;
}
size_t body = pem_string.find("\n", header);
size_t body = pem_string.find('\n', header);
if (body == std::string::npos) {
return false;
}

View File

@ -26,12 +26,12 @@ void CommandLineParser::Init(int argc, char** argv) {
}
bool CommandLineParser::IsStandaloneFlag(std::string flag) {
return flag.find("=") == std::string::npos;
return flag.find('=') == std::string::npos;
}
bool CommandLineParser::IsFlagWellFormed(std::string flag) {
size_t dash_pos = flag.find("--");
size_t equal_pos = flag.find("=");
size_t equal_pos = flag.find('=');
if (dash_pos != 0) {
fprintf(stderr, "Wrong switch format: %s\n", flag.c_str());
fprintf(stderr, "Flag doesn't start with --\n");
@ -52,7 +52,7 @@ bool CommandLineParser::IsFlagWellFormed(std::string flag) {
std::string CommandLineParser::GetCommandLineFlagName(std::string flag) {
size_t dash_pos = flag.find("--");
size_t equal_pos = flag.find("=");
size_t equal_pos = flag.find('=');
if (equal_pos == std::string::npos) {
return flag.substr(dash_pos + 2);
} else {
@ -61,7 +61,7 @@ std::string CommandLineParser::GetCommandLineFlagName(std::string flag) {
}
std::string CommandLineParser::GetCommandLineFlagValue(std::string flag) {
size_t equal_pos = flag.find("=");
size_t equal_pos = flag.find('=');
if (equal_pos == std::string::npos) {
return "";
} else {