eygraber
11/23/2023, 2:13 AMtoSet
and toMutableSet
different? Can't they both use LinkedHashSet(this)
(which seems to be more performant)?Derek Peirce
11/23/2023, 5:27 AMtoMutableSet()
uses a custom mapCapacity
method to make the set's underlying hash space slightly larger than necessary to accommodate new entries, while toSet()
is content with the JVM default as there will be no more new entries.CLOVIS
11/23/2023, 10:18 AMtoSet
has specific cases for the empty set and the singleton set (both use less memory than real sets).