-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Today, [Hash]Map.of requires recomputing the buckets: https://github.com/dart-lang/sdk/blob/main/sdk/lib/collection/hash_map.dart#L210
It should be able to specialize this method so that the private implementations in the SDK of the Map types do something more efficient, like copy buckets.
It should also be possible to specialize [Hash]Map.from similar to List.from so that it delegates to [Hash]Map.of when a cast isn't actually necessary (because the other is HashMap<K, V> in a HashMap.from for example).
Flutter runs into this problem when it tries to pass along copies of hash maps to child elements, which can happen frequently when lots of inherited widgets are involved - for example, in a large internal app it can be observed as being called 127 times, taking ~36ms of a 293ms build.
/cc @a-siva @goderbauer