diff options
author | John Reck <jreck@google.com> | 2016-11-23 10:39:40 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2016-12-02 12:49:20 -0800 |
commit | f32adf447511d54c2aa0948d3c1ef44d461538ac (patch) | |
tree | 20cff4b57e17bea6cf131cb3fa630e7320b300a0 /libs/androidfw/AttributeResolution.cpp | |
parent | 0730df7369147a5f21ef95eef347361d9ad308b3 (diff) |
Clean up ApplyStyle JNI
Bug: 32573798
Mark input uint32_t[] as const. Use Read-only JNI
array access for input as it's faster than critical access.
Use non-movable arrays for TypedArray so that the address can
be resolved and stored, avoiding the need to do JNI array
access for the output.
Indicies is always non-null, so remove the optional checks.
Eliminate unused return value.
Benchmark results:
twelveKeyInflate 4963us -> 4713us
simpleViewInflate 73us -> 60us
Test: Device boots, benchmarks show faster
Change-Id: Ic3bde5aee31407d8903913f97f2218daf074499a
Diffstat (limited to 'libs/androidfw/AttributeResolution.cpp')
-rw-r--r-- | libs/androidfw/AttributeResolution.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libs/androidfw/AttributeResolution.cpp b/libs/androidfw/AttributeResolution.cpp index 00f7a42f10e4..d71fc39802aa 100644 --- a/libs/androidfw/AttributeResolution.cpp +++ b/libs/androidfw/AttributeResolution.cpp @@ -193,9 +193,9 @@ bool ResolveAttrs(ResTable::Theme* theme, uint32_t def_style_attr, uint32_t def_ return true; } -bool ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr, - uint32_t def_style_res, uint32_t* attrs, size_t attrs_length, uint32_t* out_values, - uint32_t* out_indices) { +void ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_style_attr, + uint32_t def_style_res, const uint32_t* attrs, size_t attrs_length, + uint32_t* out_values, uint32_t* out_indices) { if (kDebugStyles) { ALOGI("APPLY STYLE: theme=0x%p defStyleAttr=0x%x defStyleRes=0x%x xml=0x%p", theme, def_style_attr, def_style_res, xml_parser); @@ -376,7 +376,7 @@ bool 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 != NULL && value.dataType != Res_value::TYPE_NULL) { + if (value.dataType != Res_value::TYPE_NULL) { indices_idx++; out_indices[indices_idx] = ii; } @@ -386,10 +386,7 @@ bool ApplyStyle(ResTable::Theme* theme, ResXMLParser* xml_parser, uint32_t def_s res.unlock(); - if (out_indices != NULL) { - out_indices[0] = indices_idx; - } - return true; + out_indices[0] = indices_idx; } bool RetrieveAttributes(const ResTable* res, ResXMLParser* xml_parser, uint32_t* attrs, |