diff options
author | 2024-04-09 12:49:48 +0000 | |
---|---|---|
committer | 2024-04-11 15:10:07 +0000 | |
commit | e8da7cd1d0e7d3535c82f8d05adcef3edd43cd40 (patch) | |
tree | f39114f368998a7b6415bb905fa71dc04dc3b232 /runtime/mirror/class.cc | |
parent | 69dc24557f951ce2513d0ea77f35a499fa58467b (diff) |
Clean up string data access in `DexFile`.
The `*ByIdx()` and `*ByTypeIdx()` functions were doing
validity checks that were needed only for processing the
debug data, so move the checks to these callers. Replace
these functions with new overloads of other functions to
provide consistent naming.
In a few cases, rewrite calls to these functions to fetch
and work with a `string_view` instead.
Rename `GetStringLength()` to `GetStringUtf16Length()` and
change its return type to `uint32_t`.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I561899606f6e5ec5f23aa4be617349dacdb376e3
Diffstat (limited to 'runtime/mirror/class.cc')
-rw-r--r-- | runtime/mirror/class.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index 7811302a13..828ab968a3 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -573,7 +573,7 @@ ArtMethod* Class::FindInterfaceMethod(ObjPtr<DexCache> dex_cache, // We always search by name and signature, ignoring the type index in the MethodId. const DexFile& dex_file = *dex_cache->GetDexFile(); const dex::MethodId& method_id = dex_file.GetMethodId(dex_method_idx); - std::string_view name = dex_file.StringViewByIdx(method_id.name_idx_); + std::string_view name = dex_file.GetStringView(method_id.name_idx_); const Signature signature = dex_file.GetMethodSignature(method_id); return FindInterfaceMethod(name, signature, pointer_size); } @@ -913,7 +913,7 @@ ArtMethod* Class::FindClassMethod(ObjPtr<DexCache> dex_cache, for (klass = this; klass != end_klass; klass = klass->GetSuperClass()) { ArraySlice<ArtMethod> copied_methods = klass->GetCopiedMethodsSlice(pointer_size); if (!copied_methods.empty() && name.empty()) { - name = dex_file.StringDataByIdx(method_id.name_idx_); + name = dex_file.GetMethodNameView(method_id); } for (ArtMethod& method : copied_methods) { if (method.GetNameView() == name && method.GetSignature() == signature) { @@ -1043,9 +1043,9 @@ static std::tuple<bool, ArtField*> FindFieldByNameAndType(const DexFile& dex_fil // Fields are sorted by class, then name, then type descriptor. This is verified in dex file // verifier. There can be multiple fields with the same name in the same class due to proguard. - // Note: std::string_view::compare() uses lexicographical comparison and treats the `char` as - // unsigned; for Modified-UTF-8 without embedded nulls this is consistent with the - // CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues() ordering. + // Note: `std::string_view::compare()` uses lexicographical comparison and treats the `char` + // as unsigned; for Modified-UTF-8 without embedded nulls this is consistent with the + // `CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues()` ordering. auto get_field_id = [&](uint32_t mid) REQUIRES_SHARED(Locks::mutator_lock_) ALWAYS_INLINE -> const dex::FieldId& { ArtField& field = fields->At(mid); |