From 29ec7aef84f4b47d89edee274562b22a177b00b8 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 6 Apr 2022 09:30:50 +0000 Subject: Use `std::string_view` for `ClassTable` operations. Use `std::string_view` instead of `const char*` descriptor. This uses faster `memcmp` instead of the slower`strcmp` for descriptor comparison. Note that the `ScopedTrace` passes `const char*` across the `libartpalette` boundary, so we cannot easily replace the `const char* descriptor` with `std::string_view descriptor` in certain `ClassLinker` functions because we actually need to pass a null-terminated string and the `string_view` API does not technically guarantee null-terminated data. Therefore we resort to explicitly passing around the descriptor and its length as separate arguments. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Bug: 338123769 Change-Id: Ie3fa251390acc582c54b4686d18696eb89b32361 --- runtime/mirror/class.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'runtime/mirror/class.h') diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 6384bfabc0..9560f985ac 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -1252,7 +1252,7 @@ class EXPORT MANAGED Class final : public Object { const char* GetDescriptor(std::string* storage) REQUIRES_SHARED(Locks::mutator_lock_); bool DescriptorEquals(ObjPtr match) REQUIRES_SHARED(Locks::mutator_lock_); - bool DescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_); + bool DescriptorEquals(std::string_view match) REQUIRES_SHARED(Locks::mutator_lock_); uint32_t DescriptorHash() REQUIRES_SHARED(Locks::mutator_lock_); @@ -1440,11 +1440,10 @@ class EXPORT MANAGED Class final : public Object { ALWAYS_INLINE uint32_t GetDirectMethodsStartOffset() REQUIRES_SHARED(Locks::mutator_lock_); bool ProxyDescriptorEquals(ObjPtr match) REQUIRES_SHARED(Locks::mutator_lock_); - bool ProxyDescriptorEquals(const char* match) REQUIRES_SHARED(Locks::mutator_lock_); + bool ProxyDescriptorEquals(std::string_view match) REQUIRES_SHARED(Locks::mutator_lock_); static uint32_t UpdateHashForProxyClass(uint32_t hash, ObjPtr proxy_class) REQUIRES_SHARED(Locks::mutator_lock_); - template void GetAccessFlagsDCheck() REQUIRES_SHARED(Locks::mutator_lock_); -- cgit v1.2.3-59-g8ed1b