diff options
author | 2021-07-05 12:18:26 +0100 | |
---|---|---|
committer | 2021-07-06 08:21:13 +0000 | |
commit | b4bd92f27fb143135870d07b459ea52637afcfa5 (patch) | |
tree | 521f811ea786e178f685316b035fe6cb0ced0605 /dexoptanalyzer/art_standalone_dexoptanalyzer_tests.xml | |
parent | 53a6334ac751aceb65d4994b81f4af815f749295 (diff) |
Faster hashing in `ClassLinker::LinkVirtualMethods()`.
Measurement shows that `ComputeModifiedUtf8Hash()` is faster
when iterating over `std::string_view` than `const char*`.
However, getting the length of the string with `strlen()`
would outweigh the benefits, so we shall only use the new
`ComputeModifiedUtf8Hash(std::string_view)` overload when
we can avoid (or usually avoid) the `strlen()` call.
In `ClassLinker::LinkVirtualMethods()`, method names come
from the dex file and we can avoid the `strlen()` call as
long as they are ASCII which is usually the case (at least
for boot class path methods; proguarded apps sometimes use
non-ASCII method names), so use `std::string_view` there.
Also simplify the code a bit, avoiding the UTF16 length
comparison. This has some trade-offs as we delay the length
comparison until we know the length in chars (and compare
that length instead) but we also replace `strcmp()` with a
faster `memcmp()`.
The changes to the Modified UTF-8 hashing API also prepare
for future work such as calculating array class descriptor
hash without a string allocation for the full descriptor.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 181943478
Change-Id: I6d45f738903000c55d401b776906dac83fca1a19
Diffstat (limited to 'dexoptanalyzer/art_standalone_dexoptanalyzer_tests.xml')
0 files changed, 0 insertions, 0 deletions