From 8ad286a19ba206224072fb84b0bd599c5d25cdbe Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 10 May 2024 14:44:09 +0200 Subject: Clean up descriptor and member name comparisons. Add helper functions for these comparisons to keep comments related to ordering in one place. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I510a1cbbb46a22ddbd39d0530198cd004b476a8d --- libdexfile/dex/method_reference.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'libdexfile/dex/method_reference.h') diff --git a/libdexfile/dex/method_reference.h b/libdexfile/dex/method_reference.h index 0472f2d492..209ab7a994 100644 --- a/libdexfile/dex/method_reference.h +++ b/libdexfile/dex/method_reference.h @@ -56,16 +56,15 @@ struct MethodReferenceValueComparator { // Compare the class descriptors first. const dex::MethodId& mid1 = mr1.GetMethodId(); const dex::MethodId& mid2 = mr2.GetMethodId(); - // 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_)); + int descriptor_diff = DexFile::CompareDescriptors( + mr1.dex_file->GetTypeDescriptorView(mid1.class_idx_), + mr2.dex_file->GetTypeDescriptorView(mid2.class_idx_)); if (descriptor_diff != 0) { return descriptor_diff < 0; } // Compare names second. - int name_diff = strcmp(mr1.dex_file->GetMethodName(mid1), mr2.dex_file->GetMethodName(mid2)); + int name_diff = DexFile::CompareMemberNames(mr1.dex_file->GetMethodNameView(mid1), + mr2.dex_file->GetMethodNameView(mid2)); if (name_diff != 0) { return name_diff < 0; } -- cgit v1.2.3-59-g8ed1b