Daniel Svensson
06/05/2020, 11:58 AMfoo.let(Bar::method)
vs foo.let { Bar.method(it) }
in terms of compiler speed, thinking that the function reference opens up to fewer possibilities compared to a block, and it could have a slight, but measurable compilation speedup if used a lot. Generating a 1000 long file with identical .let { .. }
and another file with .let(func::ref)
resulted in .let { ... }
being consistently slightly faster with 7.125 seconds vs 7.882 seconds. One hypothesis is that the function reference version is transformed to the block version during compilation, perhaps someone here knows more of the compiler internals to pitch in on that. As expected identical byte code is generated in both cases. When I then tried with Kotlin 1.4 M2, it turned out that the .let { ... }
version had become slower, and has now consistently the exact same compilation speed as the function reference. Which is the reason to why I signed up to this slack 🙂 Was hoping for the opposite as 1.4 is touted to improve compilation speed (but it's not like it's life or death which style is preferred).Zach Klippenstein (he/him) [MOD]
06/05/2020, 4:24 PMKroppeb
06/06/2020, 10:21 AMDaniel Svensson
06/06/2020, 6:50 PMKroppeb
06/06/2020, 6:57 PMDaniel Svensson
06/06/2020, 7:02 PM