summaryrefslogtreecommitdiff
path: root/tools/aapt2/optimize/ResourceDeduper.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2019-08-13 15:41:49 -0700
committerRyan Mitchell <rtmitchell@google.com>2019-08-19 17:48:46 +0000
commitf64b9d8306fe9f7a7bfcdb74974539ebc33e8f2a (patch)
treef1f06ff2ba86230ce1f01c80b4a291081df93d60 /tools/aapt2/optimize/ResourceDeduper.cpp
parentb7e133be72e32197c0fc474e1caf261e7768efc0 (diff)
Only check sibling config values to dedupe
Currently more config values are being kept than necessesary. For example, given config values for a string resource: Config: default Value: "keep" Config: ldrtl Value: "dedupe" Config: ldrtl-night Value: "dedupe" Config: land Value: "keep2" The ldrtl-night config value will fail to be removed despite being equivalent to the ldrtl value. This is because the value for the land configuration is not equivalent to the ldrtl-night value. Instead of checking that every compatible config value not related by dominance should have quivalent values, only check sibling config values within the dominator tree. Bug: 137230022 Test: aapt2_tests Change-Id: I965365d1a9433ae595eab48d82837ac102148334
Diffstat (limited to 'tools/aapt2/optimize/ResourceDeduper.cpp')
-rw-r--r--tools/aapt2/optimize/ResourceDeduper.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/aapt2/optimize/ResourceDeduper.cpp b/tools/aapt2/optimize/ResourceDeduper.cpp
index 78ebcb97b811..0278b439cfae 100644
--- a/tools/aapt2/optimize/ResourceDeduper.cpp
+++ b/tools/aapt2/optimize/ResourceDeduper.cpp
@@ -63,13 +63,14 @@ class DominatedKeyValueRemover : public DominatorTree::BottomUpVisitor {
// Compare compatible configs for this entry and ensure the values are
// equivalent.
const ConfigDescription& node_configuration = node_value->config;
- for (const auto& sibling : entry_->values) {
- if (!sibling->value) {
+ for (const auto& sibling : parent->children()) {
+ ResourceConfigValue* sibling_value = sibling->value();
+ if (!sibling_value->value) {
// Sibling was already removed.
continue;
}
- if (node_configuration.IsCompatibleWith(sibling->config) &&
- !node_value->value->Equals(sibling->value.get())) {
+ if (node_configuration.IsCompatibleWith(sibling_value->config) &&
+ !node_value->value->Equals(sibling_value->value.get())) {
// The configurations are compatible, but the value is
// different, so we can't remove this value.
return;