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}
diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
index 80e3be2..3f3077f 100644
--- a/modules/audio_coding/neteq/tools/neteq_quality_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
@@ -107,7 +107,7 @@
// 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 =
diff --git a/p2p/base/stun_port_unittest.cc b/p2p/base/stun_port_unittest.cc
index 0c428f2..31542da 100644
--- a/p2p/base/stun_port_unittest.cc
+++ b/p2p/base/stun_port_unittest.cc
@@ -223,7 +223,7 @@
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();
diff --git a/p2p/base/turn_port_unittest.cc b/p2p/base/turn_port_unittest.cc
index e8c9b5c..e5f614e 100644
--- a/p2p/base/turn_port_unittest.cc
+++ b/p2p/base/turn_port_unittest.cc
@@ -934,7 +934,7 @@
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);
diff --git a/test/frame_generator_capturer.cc b/test/frame_generator_capturer.cc
index 266cff8..a4c528e 100644
--- a/test/frame_generator_capturer.cc
+++ b/test/frame_generator_capturer.cc
@@ -31,7 +31,7 @@
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)) {
diff --git a/test/scenario/video_stream.cc b/test/scenario/video_stream.cc
index 3c368861..5525a9d 100644
--- a/test/scenario/video_stream.cc
+++ b/test/scenario/video_stream.cc
@@ -110,7 +110,7 @@
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)) {