The example here is basically an 8-fold memory saving going from `long[]` from `byte[]` - while still retaining polymorphism (whereas in Java the two are unrelated types).
Hard to say exactly how much performance one would get, as that depends on access patterns.
The reason that a byte array is in reality layed out as a (mostly empty) long array in Java, is actually for performance.
Computers tend to have their memory aligned at 8 byte intervals and accessing such an address is faster than accessing an address that's at an offset of an 8 byte interval.
Of course it depends on your use case, in some cases a compact byte array performs better anyway, for instance because now you're able to fit it in your CPU cache.
ackfoobar|9 months ago
Hard to say exactly how much performance one would get, as that depends on access patterns.
misja111|9 months ago
Of course it depends on your use case, in some cases a compact byte array performs better anyway, for instance because now you're able to fit it in your CPU cache.