X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/6ac028674a7425ad205b58d0f5e8852c1ece79c6..68cf67c743fe0d9e39465ca27f0a91415494b848:/StringPool.cpp diff --git a/StringPool.cpp b/StringPool.cpp index 46a4c32..839eda5 100644 --- a/StringPool.cpp +++ b/StringPool.cpp @@ -9,6 +9,7 @@ #include #include +#include #if HAVE_PRINTF_ZD # define ZD "%zd" @@ -71,14 +72,16 @@ String8 StringPool::entry::makeConfigsString() const { } int StringPool::entry::compare(const entry& o) const { - // Strings with styles go first, to reduce the size of the - // styles array. + // Strings with styles go first, to reduce the size of the styles array. + // We don't care about the relative order of these strings. if (hasStyles) { return o.hasStyles ? 0 : -1; } if (o.hasStyles) { return 1; } + + // Sort unstyled strings by type, then by logical configuration. int comp = configTypeName.compare(o.configTypeName); if (comp != 0) { return comp; @@ -211,11 +214,11 @@ status_t StringPool::addStyleSpan(size_t idx, const entry_style_span& span) return NO_ERROR; } -int StringPool::config_sort(const size_t* lhs, const size_t* rhs, void* state) +int StringPool::config_sort(void* state, const void* lhs, const void* rhs) { StringPool* pool = (StringPool*)state; - const entry& lhe = pool->mEntries[pool->mEntryArray[*lhs]]; - const entry& rhe = pool->mEntries[pool->mEntryArray[*rhs]]; + const entry& lhe = pool->mEntries[pool->mEntryArray[*static_cast(lhs)]]; + const entry& rhe = pool->mEntries[pool->mEntryArray[*static_cast(rhs)]]; return lhe.compare(rhe); } @@ -230,13 +233,17 @@ void StringPool::sortByConfig() // At that point it maps from the new position in the array to the // original position the entry appeared. Vector newPosToOriginalPos; - for (size_t i=0; i