writeMapOptimized

inline fun <K, V> Parcel.writeMapOptimized(map: Map<K, V>?, entryWriter: (Parcel, Map.Entry<K, V>) -> Unit)

Optimized and more feature rich way to write a map of K key-V value pairs to a Parcel.

By default, Parcel.writeMap uses Parcel.writeValue which determines the map value type at runtime and adds this type for each map value to the Parcel. This results in doubling the size of the parcel when writing an Integer map. Next both Parcel.writeMap and Parcel.writeBundle are limited to maps with Strings as keys.

This variant writes a map and uses the lambda entryWriter to write the map entries. As such, the map can have any key and value type that is supported by Parcel.