// A string is located by its DexFile and the string_ids_ table index into that DexFile. class StringReference : public DexFileReference { public:
StringReference(const DexFile* file, dex::StringIndex index)
: DexFileReference(file, index.index_) {}
// Compare the actual referenced string values. Used for string reference deduplication. struct StringReferenceValueComparator { booloperator()(const StringReference& sr1, const StringReference& sr2) const { // Note that we want to deduplicate identical strings even if they are referenced // by different dex files, so we need some (any) total ordering of strings, rather // than references. However, the references should usually be from the same dex file, // so we choose the dex file string ordering so that we can simply compare indexes // and avoid the costly string comparison in the most common case. if (sr1.dex_file == sr2.dex_file) { // Use the string order enforced by the dex file verifier.
DCHECK_EQ(
sr1.index < sr2.index,
CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(sr1.GetStringData(),
sr2.GetStringData()) < 0); return sr1.index < sr2.index;
} else { // Cannot compare indexes, so do the string comparison. return CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(sr1.GetStringData(),
sr2.GetStringData()) < 0;
}
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.