From 2b4eb676348f122ab0a21e19d7a3c57bd9898c6c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 12 Jun 2024 09:30:37 +0000 Subject: Use C++20 `string{,_view}::{starts,ends}_with()`, part 2. Replace uses of `android::base::{Starts,Ends}With()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I80a0ca93f433464270989d248dd999e9366a1c17 --- libarttools/tools.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libarttools/tools.cc') diff --git a/libarttools/tools.cc b/libarttools/tools.cc index 0dadfde564..1a4e54ed07 100644 --- a/libarttools/tools.cc +++ b/libarttools/tools.cc @@ -59,7 +59,6 @@ using ::android::base::function_ref; using ::android::base::ReadFileToString; using ::android::base::Readlink; using ::android::base::Result; -using ::android::base::StartsWith; using ::android::base::unique_fd; using ::android::fs_mgr::Fstab; using ::android::fs_mgr::FstabEntry; @@ -181,7 +180,7 @@ bool PathStartsWith(std::string_view path, std::string_view prefix) { CHECK(!prefix.empty() && !path.empty() && prefix[0] == '/' && path[0] == '/') << ART_FORMAT("path={}, prefix={}", path, prefix); ConsumeSuffix(&prefix, "/"); - return StartsWith(path, prefix) && + return path.starts_with(prefix) && (path.length() == prefix.length() || path[prefix.length()] == '/'); } @@ -197,7 +196,7 @@ static Result> GetProcMountsMatches( // field, according to fstab(5). In addition, ignore any other entries whose mount points are // not absolute paths, just in case there are other fs types that also have an meaningless mount // point. - if (entry.fs_type == "swap" || !StartsWith(entry.mount_point, '/')) { + if (entry.fs_type == "swap" || !entry.mount_point.starts_with('/')) { continue; } if (predicate(entry.mount_point)) { -- cgit v1.2.3-59-g8ed1b