Make StringPiece to be std::string_view alias
Bug: 237583012
Test: build + boot + UTs
Change-Id: I849831f4466d3b9c7ec842b75256e7fcba77a0c0
diff --git a/tools/aapt2/text/Printer.cpp b/tools/aapt2/text/Printer.cpp
index 243800c..8e491ac 100644
--- a/tools/aapt2/text/Printer.cpp
+++ b/tools/aapt2/text/Printer.cpp
@@ -26,7 +26,7 @@
namespace aapt {
namespace text {
-Printer& Printer::Println(const StringPiece& str) {
+Printer& Printer::Println(StringPiece str) {
Print(str);
return Print("\n");
}
@@ -35,7 +35,7 @@
return Print("\n");
}
-Printer& Printer::Print(const StringPiece& str) {
+Printer& Printer::Print(StringPiece str) {
if (error_) {
return *this;
}
@@ -47,7 +47,7 @@
const auto new_line_iter = std::find(remaining_str_begin, remaining_str_end, '\n');
// We will copy the string up until the next new-line (or end of string).
- const StringPiece str_to_copy = str.substr(remaining_str_begin, new_line_iter);
+ const StringPiece str_to_copy(remaining_str_begin, new_line_iter - remaining_str_begin);
if (!str_to_copy.empty()) {
if (needs_indent_) {
for (int i = 0; i < indent_level_; i++) {
diff --git a/tools/aapt2/text/Printer.h b/tools/aapt2/text/Printer.h
index f399f8e..f7ad98b 100644
--- a/tools/aapt2/text/Printer.h
+++ b/tools/aapt2/text/Printer.h
@@ -31,8 +31,8 @@
explicit Printer(::aapt::io::OutputStream* out) : out_(out) {
}
- Printer& Print(const ::android::StringPiece& str);
- Printer& Println(const ::android::StringPiece& str);
+ Printer& Print(android::StringPiece str);
+ Printer& Println(android::StringPiece str);
Printer& Println();
void Indent();
diff --git a/tools/aapt2/text/Unicode.cpp b/tools/aapt2/text/Unicode.cpp
index 3735b3e..5e25be3 100644
--- a/tools/aapt2/text/Unicode.cpp
+++ b/tools/aapt2/text/Unicode.cpp
@@ -77,7 +77,7 @@
(codepoint == 0x3000);
}
-bool IsJavaIdentifier(const StringPiece& str) {
+bool IsJavaIdentifier(StringPiece str) {
Utf8Iterator iter(str);
// Check the first character.
@@ -99,7 +99,7 @@
return true;
}
-bool IsValidResourceEntryName(const StringPiece& str) {
+bool IsValidResourceEntryName(StringPiece str) {
Utf8Iterator iter(str);
// Check the first character.
diff --git a/tools/aapt2/text/Unicode.h b/tools/aapt2/text/Unicode.h
index 546714e..ab3e82b 100644
--- a/tools/aapt2/text/Unicode.h
+++ b/tools/aapt2/text/Unicode.h
@@ -46,11 +46,11 @@
// Returns true if the UTF8 string can be used as a Java identifier.
// NOTE: This does not check against the set of reserved Java keywords.
-bool IsJavaIdentifier(const android::StringPiece& str);
+bool IsJavaIdentifier(android::StringPiece str);
// Returns true if the UTF8 string can be used as the entry name of a resource name.
// This is the `entry` part of package:type/entry.
-bool IsValidResourceEntryName(const android::StringPiece& str);
+bool IsValidResourceEntryName(android::StringPiece str);
} // namespace text
} // namespace aapt
diff --git a/tools/aapt2/text/Utf8Iterator.cpp b/tools/aapt2/text/Utf8Iterator.cpp
index 20b9073..0bd8a37 100644
--- a/tools/aapt2/text/Utf8Iterator.cpp
+++ b/tools/aapt2/text/Utf8Iterator.cpp
@@ -24,7 +24,7 @@
namespace aapt {
namespace text {
-Utf8Iterator::Utf8Iterator(const StringPiece& str)
+Utf8Iterator::Utf8Iterator(StringPiece str)
: str_(str), current_pos_(0), next_pos_(0), current_codepoint_(0) {
DoNext();
}
diff --git a/tools/aapt2/text/Utf8Iterator.h b/tools/aapt2/text/Utf8Iterator.h
index 9318401..2bba198 100644
--- a/tools/aapt2/text/Utf8Iterator.h
+++ b/tools/aapt2/text/Utf8Iterator.h
@@ -25,7 +25,7 @@
class Utf8Iterator {
public:
- explicit Utf8Iterator(const android::StringPiece& str);
+ explicit Utf8Iterator(android::StringPiece str);
bool HasNext() const;