diff options
| author | 2016-06-27 13:50:16 +0100 | |
|---|---|---|
| committer | 2016-06-27 15:53:11 +0100 | |
| commit | 5c6a58734ef0c07dbb1e951e91c66b20a25160ce (patch) | |
| tree | c9b4e7fda6b1314b3315e3ee84adc2e42fe74590 /compiler/utils/string_reference.h | |
| parent | 1e28d1e145a898e34dbb43bb655d905653e9c1e9 (diff) | |
Clean up StringReferenceValueComparator and DexFile.
Add a helper function to StringReference, so that the
StringReferenceValueComparator doesn't need to repeatedly
reference the same StringReference variable which led to
the bug 29602109.
Also clean up the DexFile, moving definitions of functions
that depend on the dex_file-inl.h from dex_file.h also to
the dex_file-inl.h.
Test: Run standard ART test suite on host and Nexus 5.
Bug: 29602109
Change-Id: I83e2aa67173c62b3432c26478e528bbb53b6d09f
Diffstat (limited to 'compiler/utils/string_reference.h')
| -rw-r--r-- | compiler/utils/string_reference.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/utils/string_reference.h b/compiler/utils/string_reference.h index 0ab45c86e3..e4c34ca605 100644 --- a/compiler/utils/string_reference.h +++ b/compiler/utils/string_reference.h @@ -29,6 +29,10 @@ namespace art { struct StringReference { StringReference(const DexFile* file, uint32_t index) : dex_file(file), string_index(index) { } + const char* GetStringData() const { + return dex_file->GetStringData(dex_file->GetStringId(string_index)); + } + const DexFile* dex_file; uint32_t string_index; }; @@ -45,15 +49,13 @@ struct StringReferenceValueComparator { // Use the string order enforced by the dex file verifier. DCHECK_EQ( sr1.string_index < sr2.string_index, - CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues( - sr1.dex_file->GetStringData(sr1.dex_file->GetStringId(sr1.string_index)), - sr2.dex_file->GetStringData(sr2.dex_file->GetStringId(sr2.string_index))) < 0); + CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(sr1.GetStringData(), + sr2.GetStringData()) < 0); return sr1.string_index < sr2.string_index; } else { // Cannot compare indexes, so do the string comparison. - return CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues( - sr1.dex_file->GetStringData(sr1.dex_file->GetStringId(sr1.string_index)), - sr2.dex_file->GetStringData(sr2.dex_file->GetStringId(sr2.string_index))) < 0; + return CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(sr1.GetStringData(), + sr2.GetStringData()) < 0; } } }; |