You get the best performance from passing primitive types by value. This is because:
- primitives are blitable, so the cost of the copy depends on the size
- primitives are small, only
double
andlong long
are bigger than a reference in most environments - pass-by-value avoids aliasing, allowing the optimizer to really do its thing
This last point is often overlooked but can make a considerable difference.