AAPT2: Ensure string pool ordering is compact
Keep styledstrings at the beginning of the StringPool
to reduce the padding in the StyledString array.
Bug:32336940
Test: manual
Change-Id: Iec820c21a54daac40ecc3b2f87517a0f1efc9d3d
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 51aed13..7d50e1d 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -533,7 +533,8 @@
if (!styleString.spans.empty()) {
// This can only be a StyledString.
return util::make_unique<StyledString>(mTable->stringPool.makeRef(
- styleString, StringPool::Context{1, mConfig}));
+ styleString,
+ StringPool::Context(StringPool::Context::kStylePriority, mConfig)));
}
auto onCreateReference = [&](const ResourceName& name) {
@@ -559,13 +560,13 @@
if (typeMask & android::ResTable_map::TYPE_STRING) {
// Use the trimmed, escaped string.
return util::make_unique<String>(mTable->stringPool.makeRef(
- styleString.str, StringPool::Context{1, mConfig}));
+ styleString.str, StringPool::Context(mConfig)));
}
if (allowRawValue) {
// We can't parse this so return a RawString if we are allowed.
return util::make_unique<RawString>(
- mTable->stringPool.makeRef(rawValue, StringPool::Context{1, mConfig}));
+ mTable->stringPool.makeRef(rawValue, StringPool::Context(mConfig)));
}
return {};
}