Add std::string StartsWith*/EndsWith* overloads.
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.
Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
diff --git a/adb/socket_spec.cpp b/adb/socket_spec.cpp
index 14eb16b..eb4df97 100644
--- a/adb/socket_spec.cpp
+++ b/adb/socket_spec.cpp
@@ -118,7 +118,7 @@
bool is_socket_spec(const std::string& spec) {
for (const auto& it : kLocalSocketTypes) {
std::string prefix = it.first + ":";
- if (StartsWith(spec, prefix.c_str())) {
+ if (StartsWith(spec, prefix)) {
return true;
}
}
@@ -128,7 +128,7 @@
bool is_local_socket_spec(const std::string& spec) {
for (const auto& it : kLocalSocketTypes) {
std::string prefix = it.first + ":";
- if (StartsWith(spec, prefix.c_str())) {
+ if (StartsWith(spec, prefix)) {
return true;
}
}
@@ -170,7 +170,7 @@
for (const auto& it : kLocalSocketTypes) {
std::string prefix = it.first + ":";
- if (StartsWith(spec, prefix.c_str())) {
+ if (StartsWith(spec, prefix)) {
if (!it.second.available) {
*error = StringPrintf("socket type %s is unavailable on this platform",
it.first.c_str());
@@ -213,7 +213,7 @@
for (const auto& it : kLocalSocketTypes) {
std::string prefix = it.first + ":";
- if (StartsWith(spec, prefix.c_str())) {
+ if (StartsWith(spec, prefix)) {
if (!it.second.available) {
*error = StringPrintf("attempted to listen on unavailable socket type: '%s'",
spec.c_str());