eclipse-collections icon indicating copy to clipboard operation
eclipse-collections copied to clipboard

Hashing-free constructor copy of HashMaps

Open syskin345 opened this issue 3 years ago • 2 comments

When creating a new HashMap from existing HashMap, the existing implementation is pretty generic: allocates the HashMap of the right capacity and loops over the input to put all entries.

However, if the input argument is exactly of the same class, it is safe and much more efficient to just clone the internal state arrays.

It's already exactly that for HashSets (although it doesn't check for exact class; it should).

syskin345 avatar Feb 20 '22 10:02 syskin345

hi @syskin345 i am a newbie to the open source code. I wanted to contribute but need your guidance as well

Kamveno avatar Sep 26 '22 16:09 Kamveno

@syskin345 Can you please give one example of good copy-constructor for HashSet and one example of bad copy-constructor for HashMap?

TheJavaGuy avatar May 16 '23 16:05 TheJavaGuy