From a4af6ef74fef1f6596dd7f4f1c5271a9edd73529 Mon Sep 17 00:00:00 2001 From: Tobias Thierer Date: Tue, 8 Oct 2019 16:18:04 +0100 Subject: Minimize default MIME map and optimize loading. This CL topic speeds up DefaultMimeMapFactory.create() from 15.5msec to 5.7msec (measured by bundling a copy of the logic and data into a test app) and saves 5.2 KByte of space (16 KBytes uncompressed) in framework.jar. This CL topic does not change the amount of heap memory consumed by the loaded MimeMap. This achieved by moving parsing steps from DefaultMimeMapFactory into a build-time optimization step. This particular CL adds this logic for debian.mime.types; see the companion CL in frameworks/base for a more in-depth explanation. Test: Checked that the mapping didn't change by checking that a device flashed after this CL passes CtsMimeMapTestCases built before this CL. Test: Ran "make mimemap-res.jar" and manually verified that files in the resulting jar look as expected. Test: Locally added some extra mappings to vendor.mime.types, some of them with a leading '?', and verified that they all show up with exactly one leading '?' for the MIME type and each extension within mimemap-res.jar. Bug: 142267887 Change-Id: I63fb4c8776e70907baf6fd2c41b74b1338f06032 --- Android.bp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Android.bp b/Android.bp index d08cd6f..33fad46 100644 --- a/Android.bp +++ b/Android.bp @@ -1,10 +1,12 @@ -filegroup { - name: "debian.mime.types", +java_genrule { + name: "debian.mime.types.minimized", visibility: [ "//visibility:public", ], - path: "", + out: ["debian.mime.types"], srcs: [ "mime.types", ], + // strip comments normalize whitepace drop empty lines + cmd: "awk '{gsub(/#.*$$/,\"\"); $$1=$$1; print;}' $(in) | grep ' ' > $(out)", } -- cgit v1.2.3