summaryrefslogtreecommitdiff
path: root/libdexfile/dex/method_reference.h
diff options
context:
space:
mode:
Diffstat (limited to 'libdexfile/dex/method_reference.h')
-rw-r--r--libdexfile/dex/method_reference.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/libdexfile/dex/method_reference.h b/libdexfile/dex/method_reference.h
index 9d4eabef2a..0472f2d492 100644
--- a/libdexfile/dex/method_reference.h
+++ b/libdexfile/dex/method_reference.h
@@ -56,8 +56,11 @@ struct MethodReferenceValueComparator {
// Compare the class descriptors first.
const dex::MethodId& mid1 = mr1.GetMethodId();
const dex::MethodId& mid2 = mr2.GetMethodId();
- int descriptor_diff = strcmp(mr1.dex_file->StringByTypeIdx(mid1.class_idx_),
- mr2.dex_file->StringByTypeIdx(mid2.class_idx_));
+ // 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.
+ int descriptor_diff = mr1.dex_file->GetTypeDescriptorView(mid1.class_idx_).compare(
+ mr2.dex_file->GetTypeDescriptorView(mid2.class_idx_));
if (descriptor_diff != 0) {
return descriptor_diff < 0;
}