https://kotlinlang.org logo
Title
k

Kstabks

11/25/2019, 12:57 PM
Hello, is there any more further explanation why actually creating a wrapper around a primitive value can be very bad for performance? I am trying to understand that in details. Regarding https://kotlinlang.org/docs/reference/inline-classes.html and the introduction
h

Holger Steinhauer [Mod]

11/25/2019, 1:01 PM
Not really a explanation but in general terms: a primitve can usually be reflected directly in memory (say written directly). For wrappers we need the whole “overhead” of an object, a pointer is needed which then points to the place in memory where the actual values are stored. This needs to be processed and the process of wrapping comes on top. So, it is more “work” needed hence the “overhead” mentioned.