is inline class overhead the same if it is just an...
# announcements
j
is inline class overhead the same if it is just an inline class with 0 methods and accessors, or if it has 1+ method, accessor, or implements interface?
d
No overhead until you throw in an interface. Even if, there shouldn't be any overhead if you call the interface method directly on the inline class.
j
virtualization is not an overhead, but are you saying the box size does change with an interface but not with just 0 or more accessors?
d
Oh? By overhead I was referring to boxing in itself.
j
i have a pair of ints. i should probably benchmark tight loops.. if the as a pair, if as an array, if as an Intarray, and inline classes of either. it normally should not come down to perofmrance or locality except when you have 1 or two ints the performance cost of memory is quite a bit higher than other objects
d
Also consider inline class with
Long
concatenation of the two
Int
s.
j
hmm yeah, and the bytebuffer mapping of same as well 🙂 I have a slightly different usecase i benchmarked not long ago. seems like i should give it a kotlin varnish and test the inline classes. https://github.com/jnorthrup/PrematureXorSwap/blob/master/SwapBenchmark.java