X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/d7ed9a895836fcb5ba7723dfb42d1dab73bc1cb0..6be9d2fef218272188077404d74f50b9f2175f54:/StringPool.cpp diff --git a/StringPool.cpp b/StringPool.cpp index b6295bd..a9941b4 100644 --- a/StringPool.cpp +++ b/StringPool.cpp @@ -213,7 +213,11 @@ status_t StringPool::addStyleSpan(size_t idx, const entry_style_span& span) return NO_ERROR; } +#ifdef __GLIBC__ +int StringPool::config_sort(const void* lhs, const void* rhs, void* state) +#else int StringPool::config_sort(void* state, const void* lhs, const void* rhs) +#endif { StringPool* pool = (StringPool*)state; const entry& lhe = pool->mEntries[pool->mEntryArray[*static_cast(lhs)]]; @@ -241,7 +245,13 @@ void StringPool::sortByConfig() NOISY(printf("SORTING STRINGS BY CONFIGURATION...\n")); // Vector::sort uses insertion sort, which is very slow for this data set. // Use quicksort instead because we don't need a stable sort here. + // For more fun, GLibC took qsort_r from BSD but then decided to swap the + // order the last two parameters. +#ifdef __GLIBC__ + qsort_r(newPosToOriginalPos.editArray(), N, sizeof(size_t), config_sort, this); +#else qsort_r(newPosToOriginalPos.editArray(), N, sizeof(size_t), this, config_sort); +#endif //newPosToOriginalPos.sort(config_sort, this); NOISY(printf("DONE SORTING STRINGS BY CONFIGURATION.\n"));