Optimize calls to std::string::find() and friends for a single char.
The character literal overload is more efficient. No-Presubmit: True No-Try: True Bug: None Change-Id: Ice0b8478accd8a252ab81a0496d46c0f71db3db6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/197810 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32841}
This commit is contained in:
parent
0e7b3a9dad
commit
5686e3457e
@ -107,7 +107,7 @@ const int kPacketLossTimeUnitMs = 10;
|
||||
// Common validator for file names.
|
||||
static bool ValidateFilename(const std::string& value, bool is_output) {
|
||||
if (!is_output) {
|
||||
RTC_CHECK_NE(value.substr(value.find_last_of(".") + 1), "wav")
|
||||
RTC_CHECK_NE(value.substr(value.find_last_of('.') + 1), "wav")
|
||||
<< "WAV file input is not supported";
|
||||
}
|
||||
FILE* fid =
|
||||
|
||||
@ -223,7 +223,7 @@ TEST_F(StunPortTest, TestPrepareAddressFail) {
|
||||
EXPECT_EQ_SIMULATED_WAIT(error_event_.error_code,
|
||||
cricket::SERVER_NOT_REACHABLE_ERROR, kTimeoutMs,
|
||||
fake_clock);
|
||||
ASSERT_NE(error_event_.error_text.find("."), std::string::npos);
|
||||
ASSERT_NE(error_event_.error_text.find('.'), std::string::npos);
|
||||
ASSERT_NE(error_event_.address.find(kLocalAddr.HostAsSensitiveURIString()),
|
||||
std::string::npos);
|
||||
std::string server_url = "stun:" + kBadAddr.ToString();
|
||||
|
||||
@ -934,7 +934,7 @@ TEST_F(TurnPortTest,
|
||||
EXPECT_TRUE_SIMULATED_WAIT(turn_error_, kSimulatedRtt, fake_clock_);
|
||||
EXPECT_EQ_SIMULATED_WAIT(error_event_.error_code, STUN_ERROR_GLOBAL_FAILURE,
|
||||
kSimulatedRtt, fake_clock_);
|
||||
ASSERT_NE(error_event_.error_text.find("."), std::string::npos);
|
||||
ASSERT_NE(error_event_.error_text.find('.'), std::string::npos);
|
||||
ASSERT_NE(error_event_.address.find(kLocalAddr2.HostAsSensitiveURIString()),
|
||||
std::string::npos);
|
||||
ASSERT_NE(error_event_.port, 0);
|
||||
|
||||
@ -31,7 +31,7 @@ namespace test {
|
||||
namespace {
|
||||
std::string TransformFilePath(std::string path) {
|
||||
static const std::string resource_prefix = "res://";
|
||||
int ext_pos = path.rfind(".");
|
||||
int ext_pos = path.rfind('.');
|
||||
if (ext_pos < 0) {
|
||||
return test::ResourcePath(path, "yuv");
|
||||
} else if (absl::StartsWith(path, resource_prefix)) {
|
||||
|
||||
@ -110,7 +110,7 @@ std::vector<RtpExtension> GetVideoRtpExtensions(
|
||||
|
||||
std::string TransformFilePath(std::string path) {
|
||||
static const std::string resource_prefix = "res://";
|
||||
int ext_pos = path.rfind(".");
|
||||
int ext_pos = path.rfind('.');
|
||||
if (ext_pos < 0) {
|
||||
return test::ResourcePath(path, "yuv");
|
||||
} else if (absl::StartsWith(path, resource_prefix)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user