summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2019-10-08 16:18:04 +0100
committerTobias Thierer <tobiast@google.com>2019-10-08 21:03:07 +0100
commita4af6ef74fef1f6596dd7f4f1c5271a9edd73529 (patch)
tree1f03313acaed91318fa9604a20f97ca4c8353ad3
parent21e648108d1b82410a1ab335692115f8f492e4c0 (diff)
downloadmime-support-a4af6ef74fef1f6596dd7f4f1c5271a9edd73529.tar.gz
Minimize default MIME map and optimize loading.ndk-sysroot-r21
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
-rw-r--r--Android.bp8
1 files 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)",
}