summaryrefslogtreecommitdiff
path: root/libs/androidfw/AttributeResolution.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-01-05 17:03:55 -0800
committerAdam Lesinski <adamlesinski@google.com>2017-01-06 16:51:48 -0800
commit06d3e8fec7e2b29f99d755bee849023d88957953 (patch)
tree328055c7a9632e9660e836d4dfd0cfcc0450700e /libs/androidfw/AttributeResolution.cpp
parent0a454c39cb5bc03cd646546aa3b8baaed1962178 (diff)
libandroidfw: Revert null check in ApplyStyle
The out parameter `out_indices` is expected to be non-null and so the extra null check adds a cost to performance and opens the door to misusing the API by not supplying `out_indices`. Test: make libandroidfw_tests Change-Id: Ie66fd837c5e24ec2838156e7b67f54c15cd27933
Diffstat (limited to 'libs/androidfw/AttributeResolution.cpp')
-rw-r--r--libs/androidfw/AttributeResolution.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/libs/androidfw/AttributeResolution.cpp b/libs/androidfw/AttributeResolution.cpp
index f5aef05e8842..d433b90f14f0 100644
--- a/libs/androidfw/AttributeResolution.cpp
+++ b/libs/androidfw/AttributeResolution.cpp
@@ -418,8 +418,10 @@ void ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_s
out_values[STYLE_CHANGING_CONFIGURATIONS] = type_set_flags;
out_values[STYLE_DENSITY] = config.density;
- if (out_indices != nullptr && value.dataType != Res_value::TYPE_NULL) {
+ if (value.dataType != Res_value::TYPE_NULL) {
indices_idx++;
+
+ // out_indices must NOT be nullptr.
out_indices[indices_idx] = ii;
}
@@ -428,9 +430,8 @@ void ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_s
res.unlock();
- if (out_indices != nullptr) {
- out_indices[0] = indices_idx;
- }
+ // out_indices must NOT be nullptr.
+ out_indices[0] = indices_idx;
}
bool RetrieveAttributes(const ResTable* res, ResXMLParser* xml_parser,