What we do: 1. Inline functions (not really an "op...
# language-proposals
d
What we do: 1. Inline functions (not really an "optimization", but) - avoid unnecessary heap allocation and class/method generation for lambdas. Inlining is performed on bytecode-level and allows more extensive bytecode-level transformations. 2. Some expressions (
for
,
when
, string templates / string concatenation) have specific code generation schemes (e.g.,
for
over a range,
when
by constant selectors, etc) that produce "optimized" bytecode. 3. A few functions and properties are implemented as compiler intrinsics (yet again, a particular bytecode generation scheme provided by compiler). Sometimes it can be treated as an "optimization". E.g.,
A::class.java
doesn't create an intermediate KClass object. 4. Bytecode postprocessing steps eliminate redundant boxing/unboxing, redundant null checks, and dead code. Such transformations are intraprocedural (that is, within a context of a single method), so, as mentioned above, inline functions provide additional benefits here.