Kotlin / kotlinx.collections.immutable

Immutable persistent collections for Kotlin
Apache License 2.0
1.16k stars 59 forks source link

Please cache the hashCode #126

Closed zajac closed 2 years ago

zajac commented 2 years ago

I think, hashCode could and should be cached for persistent data structures.

randomnetcat commented 2 years ago

hashCode can't be cached if the elements of the container are mutable, because the hashCode could then change without the container knowing.

zajac commented 2 years ago

You're correct, it would not be correct thing to do on the library level.