diff options
author | 2024-05-06 07:43:35 +0000 | |
---|---|---|
committer | 2024-05-09 09:24:11 +0000 | |
commit | 1ca987e8b5cc2b9b3a15fc8187b987678c54b899 (patch) | |
tree | 27d9c4d9406713d2287e2e9abfbb068198a02d50 /runtime/class_table-inl.h | |
parent | 8e4b50a62ddb7ecfecb3e0caf3cab9f0e35eee76 (diff) |
Avoid some `std::string` construction in `ClassTable`.
Do not construct a `std::string` when compaing most class
descriptors for `Class` objects. We still construct it for
the edge case when comparing a proxy class and non-proxy
class descriptors which should really yield false, except
that ART does not propely enforce the namespace separation.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 338123769
Change-Id: I001abf9dd6648621e86f43a8234d2c0c1d02471c
Diffstat (limited to 'runtime/class_table-inl.h')
-rw-r--r-- | runtime/class_table-inl.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h index 8a8487c412..2ea49dbef0 100644 --- a/runtime/class_table-inl.h +++ b/runtime/class_table-inl.h @@ -32,8 +32,9 @@ inline ClassTable::TableSlot::TableSlot(ObjPtr<mirror::Class> klass) : TableSlot(klass, klass->DescriptorHash()) {} inline uint32_t ClassTable::ClassDescriptorHash::operator()(const TableSlot& slot) const { - // No read barriers needed, we're reading a chain of constant references for comparison with null - // and retrieval of constant primitive data. See `ReadBarrierOption` and `Class::DescriptorHash()`. + // No read barriers needed, we're reading a chain of constant references + // for comparison with null and retrieval of constant primitive data. + // See `ReadBarrierOption` and `Class::DescriptorHash()`. return slot.Read<kWithoutReadBarrier>()->DescriptorHash(); } @@ -44,17 +45,14 @@ inline uint32_t ClassTable::ClassDescriptorHash::operator()(const DescriptorHash inline bool ClassTable::ClassDescriptorEquals::operator()(const TableSlot& a, const TableSlot& b) const { - // No read barrier needed, we're reading a chain of constant references for comparison - // with null and retrieval of constant primitive data. See ReadBarrierOption. + // No read barrier needed, we're reading a chain of constant references + // for comparison with null and retrieval of constant primitive data. + // See ReadBarrierOption and `Class::DescriptorEquals()`. if (a.Hash() != b.Hash()) { - std::string temp; - DCHECK(!a.Read<kWithoutReadBarrier>()->DescriptorEquals( - b.Read<kWithoutReadBarrier>()->GetDescriptor(&temp))); + DCHECK(!a.Read<kWithoutReadBarrier>()->DescriptorEquals(b.Read<kWithoutReadBarrier>())); return false; } - std::string temp; - return a.Read<kWithoutReadBarrier>()->DescriptorEquals( - b.Read<kWithoutReadBarrier>()->GetDescriptor(&temp)); + return a.Read<kWithoutReadBarrier>()->DescriptorEquals(b.Read<kWithoutReadBarrier>()); } inline bool ClassTable::ClassDescriptorEquals::operator()(const TableSlot& a, |