Make StringPiece to be std::string_view alias
Bug: 237583012
Test: build + boot + UTs
Change-Id: I849831f4466d3b9c7ec842b75256e7fcba77a0c0
diff --git a/tools/aapt2/optimize/MultiApkGenerator.cpp b/tools/aapt2/optimize/MultiApkGenerator.cpp
index f994e27..f01db3d 100644
--- a/tools/aapt2/optimize/MultiApkGenerator.cpp
+++ b/tools/aapt2/optimize/MultiApkGenerator.cpp
@@ -113,12 +113,12 @@
};
class SignatureFilter : public IPathFilter {
- bool Keep(const std::string& path) override {
+ bool Keep(std::string_view path) override {
static std::regex signature_regex(R"regex(^META-INF/.*\.(RSA|DSA|EC|SF)$)regex");
- if (std::regex_search(path, signature_regex)) {
+ if (std::regex_search(path.begin(), path.end(), signature_regex)) {
return false;
}
- return !(path == "META-INF/MANIFEST.MF");
+ return path != "META-INF/MANIFEST.MF";
}
};
diff --git a/tools/aapt2/optimize/Obfuscator.cpp b/tools/aapt2/optimize/Obfuscator.cpp
index f704f26..1fdd728 100644
--- a/tools/aapt2/optimize/Obfuscator.cpp
+++ b/tools/aapt2/optimize/Obfuscator.cpp
@@ -35,7 +35,7 @@
Obfuscator::Obfuscator(std::map<std::string, std::string>& path_map_out) : path_map_(path_map_out) {
}
-std::string ShortenFileName(const android::StringPiece& file_path, int output_length) {
+std::string ShortenFileName(android::StringPiece file_path, int output_length) {
std::size_t hash_num = std::hash<android::StringPiece>{}(file_path);
std::string result = "";
// Convert to (modified) base64 so that it is a proper file path.
@@ -58,9 +58,9 @@
}
}
-std::string GetShortenedPath(const android::StringPiece& shortened_filename,
- const android::StringPiece& extension, int collision_count) {
- std::string shortened_path = "res/" + shortened_filename.to_string();
+std::string GetShortenedPath(android::StringPiece shortened_filename,
+ android::StringPiece extension, int collision_count) {
+ std::string shortened_path = std::string("res/") += shortened_filename;
if (collision_count > 0) {
shortened_path += std::to_string(collision_count);
}
diff --git a/tools/aapt2/optimize/VersionCollapser_test.cpp b/tools/aapt2/optimize/VersionCollapser_test.cpp
index aa0d0c0..18dcd6b 100644
--- a/tools/aapt2/optimize/VersionCollapser_test.cpp
+++ b/tools/aapt2/optimize/VersionCollapser_test.cpp
@@ -23,7 +23,7 @@
namespace aapt {
static std::unique_ptr<ResourceTable> BuildTableWithConfigs(
- const StringPiece& name, std::initializer_list<std::string> list) {
+ StringPiece name, std::initializer_list<std::string> list) {
test::ResourceTableBuilder builder;
for (const std::string& item : list) {
builder.AddSimple(name, test::ParseConfigOrDie(item));