summaryrefslogtreecommitdiff
path: root/runtime/class_table.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2022-04-06 09:30:50 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2024-11-05 15:24:05 +0000
commit29ec7aef84f4b47d89edee274562b22a177b00b8 (patch)
treef958dafda289458ce7dac0ad86f7596636ee7ecf /runtime/class_table.cc
parent96dc77238e2b5a962911a6da06d5e1b869dc92f8 (diff)
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
Diffstat (limited to 'runtime/class_table.cc')
-rw-r--r--runtime/class_table.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/class_table.cc b/runtime/class_table.cc
index 35d3537478..5a20c2f576 100644
--- a/runtime/class_table.cc
+++ b/runtime/class_table.cc
@@ -104,7 +104,7 @@ size_t ClassTable::NumReferencedNonZygoteClasses() const {
return classes_.back().size();
}
-ObjPtr<mirror::Class> ClassTable::Lookup(const char* descriptor, size_t hash) {
+ObjPtr<mirror::Class> ClassTable::Lookup(std::string_view descriptor, size_t hash) {
DescriptorHashPair pair(descriptor, hash);
ReaderMutexLock mu(Thread::Current(), lock_);
// Search from the last table, assuming that apps shall search for their own classes