MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / StringReferenceValueComparator

Class StringReferenceValueComparator

Bcore/src/main/cpp/dex/string_reference.h:47–67  ·  view source on GitHub ↗

Compare the actual referenced string values. Used for string reference deduplication.

Source from the content-addressed store, hash-verified

45
46// Compare the actual referenced string values. Used for string reference deduplication.
47struct StringReferenceValueComparator {
48 bool operator()(const StringReference& sr1, const StringReference& sr2) const {
49 // Note that we want to deduplicate identical strings even if they are referenced
50 // by different dex files, so we need some (any) total ordering of strings, rather
51 // than references. However, the references should usually be from the same dex file,
52 // so we choose the dex file string ordering so that we can simply compare indexes
53 // and avoid the costly string comparison in the most common case.
54 if (sr1.dex_file == sr2.dex_file) {
55 // Use the string order enforced by the dex file verifier.
56 DCHECK_EQ(
57 sr1.index < sr2.index,
58 CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(sr1.GetStringData(),
59 sr2.GetStringData()) < 0);
60 return sr1.index < sr2.index;
61 } else {
62 // Cannot compare indexes, so do the string comparison.
63 return CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(sr1.GetStringData(),
64 sr2.GetStringData()) < 0;
65 }
66 }
67};
68
69} // namespace art_lkchan
70

Callers 1

operator()Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected