Join Slack
Communities
Powered by
whats the downside of using `lazy` delegate?
# android
p
pawel.rybicki
05/02/2017, 1:38 PM
whats the downside of using
lazy
delegate?
stackoverflow
6
w
wasyl
05/02/2017, 1:40 PM
pawel.rybicki: Additional object allocation for lazy instance, second field for value, and overhead when getting value - basically what you see here
https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/util/Lazy.kt
m
menegatti
05/02/2017, 1:42 PM
It is also thread safe, so the lock on the field helps with the overhead
menegatti
05/02/2017, 1:43 PM
there are different modes, as you can see here
https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/util/Lazy.kt#L54
p
pawel.rybicki
05/02/2017, 2:44 PM
thanks : )
8
Views
Open in Slack
Previous
Next