Files
kotlin-fork/libraries/stdlib/common
Filipp Zhinkin 368f21461c KT-55091 Optimize Sequence::toSet/toList implementation
Sequence::toSet and Sequence::toList both create a
collection, fill it with elements, and then try to optimize a result
by returning empty, singleton, or the allocated collection depending on
the elements count.
Instead of allocating the collection and then trying to return
an optimized instance it is worth checking the sequence's size
beforehand and return empty/singleton collection when possible.

Proposed change optimize performance of aforementioned functions and
also reduce allocation rate when a sequence consists of 0 or 1 elements.

^KT-55091 fixed
2023-04-17 08:58:20 +00:00
..
2023-02-24 17:05:33 +00:00