summaryrefslogtreecommitdiff
path: root/tools/aapt2/StringPool.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-08-14 14:26:04 -0700
committerAdam Lesinski <adamlesinski@google.com>2015-10-16 12:13:08 -0700
commit1ab598f46c3ff520a67f9d80194847741f3467ab (patch)
tree4846790211599fdd7a9bb35ec94df4a6ec4839d6 /tools/aapt2/StringPool.cpp
parent547c346bb34878b691fd53e54aa3a88efcc5dc6f (diff)
AAPT2: Separate out the various steps
An early refactor. Some ideas became clearer as development continued. Now the various phases are much clearer and more easily reusable. Also added a ton of tests! Change-Id: Ic8f0a70c8222370352e63533b329c40457c0903e
Diffstat (limited to 'tools/aapt2/StringPool.cpp')
-rw-r--r--tools/aapt2/StringPool.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/aapt2/StringPool.cpp b/tools/aapt2/StringPool.cpp
index c19aa98a70ac..8552f470b123 100644
--- a/tools/aapt2/StringPool.cpp
+++ b/tools/aapt2/StringPool.cpp
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#include "BigBuffer.h"
-#include "StringPiece.h"
+#include "util/BigBuffer.h"
+#include "util/StringPiece.h"
#include "StringPool.h"
-#include "Util.h"
+#include "util/Util.h"
#include <algorithm>
#include <androidfw/ResourceTypes.h>
@@ -219,7 +219,7 @@ void StringPool::prune() {
auto indexIter = std::begin(mIndexedStrings);
while (indexIter != iterEnd) {
if (indexIter->second->ref <= 0) {
- mIndexedStrings.erase(indexIter++);
+ indexIter = mIndexedStrings.erase(indexIter);
} else {
++indexIter;
}
@@ -241,6 +241,12 @@ void StringPool::prune() {
// a deleted string from the StyleEntry.
mStrings.erase(endIter2, std::end(mStrings));
mStyles.erase(endIter3, std::end(mStyles));
+
+ // Reassign the indices.
+ const size_t len = mStrings.size();
+ for (size_t index = 0; index < len; index++) {
+ mStrings[index]->index = index;
+ }
}
void StringPool::sort(const std::function<bool(const Entry&, const Entry&)>& cmp) {