Replace StringPiece with std::string_view in Signature.
And also in Signature-related code. Remove the function
DexFile::CreateSignature() which was used only in a test
as the test can use method searching functions that take
std::string_view instead.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 123750182
Change-Id: I3f24c8f4f677e2e40503dbab347df1eb031b4132
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index 2f37123..a2775d2 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -1254,7 +1254,7 @@
EXPECT_TRUE(K->IsAssignableFrom(B.Get()));
EXPECT_TRUE(J->IsAssignableFrom(B.Get()));
- const Signature void_sig = I->GetDexCache()->GetDexFile()->CreateSignature("()V");
+ const std::string_view void_sig("()V");
ArtMethod* Ii = I->FindClassMethod("i", void_sig, kRuntimePointerSize);
ArtMethod* Jj1 = J->FindClassMethod("j1", void_sig, kRuntimePointerSize);
ArtMethod* Jj2 = J->FindClassMethod("j2", void_sig, kRuntimePointerSize);
diff --git a/runtime/jni/jni_internal.cc b/runtime/jni/jni_internal.cc
index af86cc0..7c0db30 100644
--- a/runtime/jni/jni_internal.cc
+++ b/runtime/jni/jni_internal.cc
@@ -442,8 +442,8 @@
template <bool kNative>
static ArtMethod* FindMethod(ObjPtr<mirror::Class> c,
- const StringPiece& name,
- const StringPiece& sig)
+ std::string_view name,
+ std::string_view sig)
REQUIRES_SHARED(Locks::mutator_lock_) {
auto pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
for (auto& method : c->GetMethods(pointer_size)) {
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index c3f7ad7..872095a 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -21,7 +21,6 @@
#include "art_field-inl.h"
#include "art_method-inl.h"
#include "base/logging.h" // For VLOG.
-#include "base/stringpiece.h"
#include "base/utils.h"
#include "class-inl.h"
#include "class_ext.h"
@@ -482,9 +481,7 @@
ArtMethod* Class::FindInterfaceMethod(std::string_view name,
std::string_view signature,
PointerSize pointer_size) {
- // TODO: Change Signature::operator==() to accept std::string_view instead of StringPiece.
- StringPiece sp_signature(signature.data(), signature.size());
- return FindInterfaceMethodWithSignature(this, name, sp_signature, pointer_size);
+ return FindInterfaceMethodWithSignature(this, name, signature, pointer_size);
}
ArtMethod* Class::FindInterfaceMethod(std::string_view name,
@@ -597,9 +594,7 @@
ArtMethod* Class::FindClassMethod(std::string_view name,
std::string_view signature,
PointerSize pointer_size) {
- // TODO: Change Signature::operator==() to accept std::string_view instead of StringPiece.
- StringPiece sp_signature(signature.data(), signature.size());
- return FindClassMethodWithSignature(this, name, sp_signature, pointer_size);
+ return FindClassMethodWithSignature(this, name, signature, pointer_size);
}
ArtMethod* Class::FindClassMethod(std::string_view name,
@@ -707,13 +702,11 @@
}
ArtMethod* Class::FindConstructor(std::string_view signature, PointerSize pointer_size) {
- // TODO: Change Signature::operator==() to accept std::string_view instead of StringPiece.
- StringPiece sp_signature(signature.data(), signature.size());
// Internal helper, never called on proxy classes. We can skip GetInterfaceMethodIfProxy().
DCHECK(!IsProxyClass());
std::string_view name("<init>");
for (ArtMethod& method : GetDirectMethodsSliceUnchecked(pointer_size)) {
- if (method.GetName() == name && method.GetSignature() == sp_signature) {
+ if (method.GetName() == name && method.GetSignature() == signature) {
return &method;
}
}