Open mkeskells opened 7 years ago
I looked the implementation of LinkedHashSet, createNewEntry
doesn't rely on the value:
protected def createNewEntry[B](key: A, dummy: B): Entry = {
val e = new Entry(key)
if (firstEntry eq null) firstEntry = e
else { lastEntry.later = e; e.earlier = lastEntry }
lastEntry = e
e
}
So the maintained hashcode is still key's hashCode. The hotspot shown by jprofiler probably is because numeration operations (like bit shift) in scala cost too long?
HashTables ( e.g. mutable.HashSet) use an Entry that maintains the key and value, but not the hash
this means that the collisions are expensive, and resize is expensive
Investigate the performance that having a hash would provide, using jmh