summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher R. Palmer <crpalmer@gmail.com>2016-01-04 05:18:31 -0500
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-01-04 13:04:25 -0800
commitd75ef880799006156be52f4552a1640092ad4060 (patch)
tree3be02d5c6a891d04b54a0d9ff77ef15511b737a5
parentf3ebbf7a273945ba09635f1b611a7a79ed440456 (diff)
downloadframeworks_base-d75ef880799006156be52f4552a1640092ad4060.zip
frameworks_base-d75ef880799006156be52f4552a1640092ad4060.tar.gz
frameworks_base-d75ef880799006156be52f4552a1640092ad4060.tar.bz2
aapt: Speed up the style pruning
Prior to this commit it removed each style one by one which causes the vector to repeatedly be shrunk and reallocated and copied (aka either quadratic or NlogN in the number of items removed). This commit simply makes it remove them all at once to make it linear instead. Change-Id: I541d151675ab19f37d9de1e7a323104d0d3b3c63
-rw-r--r--tools/aapt/StringPool.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp
index 9908c44..e449896 100644
--- a/tools/aapt/StringPool.cpp
+++ b/tools/aapt/StringPool.cpp
@@ -349,14 +349,18 @@ void StringPool::sortByConfig()
// Now trim any entries at the end of the new style array that are
// not needed.
- for (ssize_t i=newEntryStyleArray.size()-1; i>=0; i--) {
+ ssize_t i;
+ for (i=newEntryStyleArray.size()-1; i>=0; i--) {
const entry_style& style = newEntryStyleArray[i];
if (style.spans.size() > 0) {
// That's it.
break;
}
- // This one is not needed; remove.
- newEntryStyleArray.removeAt(i);
+ }
+
+ ssize_t nToRemove=newEntryStyleArray.size()-(i+1);
+ if (nToRemove) {
+ newEntryStyleArray.removeItemsAt(i+1, nToRemove);
}
// All done, install the new data structures and upate mValues with