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/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index b19ab78..f81206a 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -315,8 +315,7 @@
for (auto& s : knownReasons) {
if (s == "cold") break;
// Prefix defined as terminated by a nul or comma (,).
- if (android::base::StartsWith(r, s.c_str()) &&
- ((r.length() == s.length()) || (r[s.length()] == ','))) {
+ if (android::base::StartsWith(r, s) && ((r.length() == s.length()) || (r[s.length()] == ','))) {
return true;
}
}
@@ -328,8 +327,7 @@
for (auto& s : knownReasons) {
if (s == "recovery") break;
// Prefix defined as terminated by a nul or comma (,).
- if (android::base::StartsWith(r, s.c_str()) &&
- ((r.length() == s.length()) || (r[s.length()] == ','))) {
+ if (android::base::StartsWith(r, s) && ((r.length() == s.length()) || (r[s.length()] == ','))) {
return true;
}
}
@@ -340,8 +338,7 @@
bool isKnownRebootReason(const std::string& r) {
for (auto& s : knownReasons) {
// Prefix defined as terminated by a nul or comma (,).
- if (android::base::StartsWith(r, s.c_str()) &&
- ((r.length() == s.length()) || (r[s.length()] == ','))) {
+ if (android::base::StartsWith(r, s) && ((r.length() == s.length()) || (r[s.length()] == ','))) {
return true;
}
}