Not sure if this belongs here, but why are the imp...
# language-evolution
e
Not sure if this belongs here, but why are the implementations of
toSet
and
toMutableSet
different? Can't they both use
LinkedHashSet(this)
(which seems to be more performant)?
d
From what I can tell,
toMutableSet()
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.
c
Iterable.toSetIterable.toMutableSet
toSet
has specific cases for the empty set and the singleton set (both use less memory than real sets).
1