MimeMap: Construct libcore's default instance lazily, too.
Dashboards still suggest a 1-2msec regression vs. historic zygote pre-fork time.
This appears likely to be because of the eager construction of libcore's default
MimeMap instance during MimeMap.<clinit>. Since, in practice, this instance is
never used because RuntimeInit.preForkInit() calls MimeMap.setDefaultProvider()
before anything else calls MimeMap.getDefault(), this is useless work. This CL
changes MimeMap.<clinit> to only construct a Supplier of that default instance.
That Supplier is then (in practice) never invoked.
To avoid introducing yet another (lambda) class, this CL also drops the
helper method MimeMap.setDefault() and the tests that were specifically
testing that method. Remaining tests are refactored to instead use
MimeMap.setDefaultSupplier().
MimeMap.instanceSupplier's compile-time type is changed to
MemoizingSupplier because it always has that type in practice and because
that has the side effect of documenting this fact.
Test: atest CtsMimeMapTestCases \
CtsLibcoreTestCases:libcore.libcore.content.type.MimeMapTest
Bug: 142019040
Change-Id: I078b74a81f1cdafbdd0d168d1d698f4db58054c1
2 files changed