Implement MicroMap #1201
Description
Maps are used often in Angular. Most of the maps have fewer than 20 keys, yet they create many objects. For small maps it is more efficient to do a linear search of fields than to do full bucket algorithm. See: mhevery@3290683 This test shows that break even point in Dart VM is 3 fields and Dart2JS is 17 fields.
Create a class MicroMap
(also MicroMapIdentity
) which implements Map
interface but which if it has less than 20 keys it will use fields but if more than 20 it will create a real HashMap delegate and forward all of the calls to the delegate. (Also move the contents of the fields there.) This way we can take advantage of the efficient storage MicroMap
but auto move to real map as needed.
Not all methods need to be implemented. Just the basics such as read
, write
, remove
, length
.