| I'm not entirely convinced that this is a good idea, do you have evidence of us systemically wasting space? Remember that in a HashMap it's quite possible that several items will resolve to the same bucket, so it's a normal scenario to have less buckets allocated than the total size of entries. The "putAll" method does indeed apply some correction factor; I don't know why they came to this conclusion but my wild guess is that it's taking in consideration that it's adding N elements in addition to existing items. Clearly some people thought this through and decided that it wasn't worth to apply on the constructor invocation. The main doubt I have is wondering if this slight offset in allocation is something you have observed in a specific use case: in this case we should just have either a dedicate method on CollectionHelper, or get rid of the helper so that each code path takes responsibility. If you think this is "globally" needed - like that the default constructor is just wrong - then it would be nice to share your observations to the OpenJDK team. |