368f21461c
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
Code Generation for Standard Library
Some of the code in the standard library is created by code generation based on templates.
For example, many Array methods need to be implemented separately for Array<T>, ByteArray, ShortArray, IntArray, etc.
To run the code generator use the following command in the root directory of the project:
./gradlew :tools:kotlin-stdlib-gen:run
Note: on Windows type
gradlewwithout the leading./
This then runs the script which generates a significant part of stdlib sources from the templates authored with a special kotlin based DSL.