-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
scala/scala
#7348Description
Some findings from benchmarking mutable.HashSet:
- Doesn't handle primitives correctly (using
.hashCodeinstead of.##) - Considerably slower than Java's HashSet (
mutable.HashMapused as a Set is even slower) - Uses open addressing with a high load factory: This can be useful in some cases but is probably not the best default, especially on the JVM where open addressing can't play to its full strength
- Doesn't cache hash codes (unlike our other standard hash-based collections): This can lead to surprising performance if elements can't compute hashes cheaply
- Doesn't support size hints for efficient bulk building
- Like our other Set and Map types it is vulnerable to DoS vulnerability in Scala 2.12 HashMap bug#11203
We should replace it with a more "standard" implementation (chaining via linked lists, cached hash codes) for predictable performance that is consistent with mutable.HashMap and java.util.HashSet.
The current version could live on as OpenHashSet, consistent with OpenHashMap. OTOH, OpenHashMap is deprecated.
Metadata
Metadata
Assignees
Labels
No labels