Add ResTable_sparseTypeEntry support
Benchmarks on bullhead-userdebug show that there is a negligent
performance impact when using sparse entries on a 30% loaded
sparse type of 1000 resources.
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------
BM_SparseEntryGetResourceSparseLarge 255 ns 254 ns 2751408
BM_SparseEntryGetResourceNotSparseLarge 254 ns 254 ns 2756534
Bug: 27381711
Test: make libandroidfw_tests aapt2_tests
Change-Id: I051ea22f2f6b2bc3696e446adc9e2a34be18009f
diff --git a/tools/aapt2/LoadedApk.cpp b/tools/aapt2/LoadedApk.cpp
index 3d7bd94..407550b 100644
--- a/tools/aapt2/LoadedApk.cpp
+++ b/tools/aapt2/LoadedApk.cpp
@@ -94,7 +94,9 @@
// The resource table needs to be reserialized since it might have changed.
if (path == "resources.arsc") {
BigBuffer buffer = BigBuffer(1024);
- TableFlattener flattener(&buffer);
+ // TODO(adamlesinski): How to determine if there were sparse entries (and if to encode
+ // with sparse entries) b/35389232.
+ TableFlattener flattener({}, &buffer);
if (!flattener.Consume(context, table_.get())) {
return false;
}