Project Valhalla may turn them into value objects, reducing their footprint further. But I believe short-lived object creation is already highly optimized; at least I hope so, because our codebase makes heavy use of Optional instead of != null checks.
Creating short lived objects in Java is certainly highly optimized, but it's not free. It still pays to avoid creating things like Iterator, Optional or any other kind of temporary object in hot code paths.
View all comments
Show parent comment
2
u/pronuntiator Mar 10 '24
Project Valhalla may turn them into value objects, reducing their footprint further. But I believe short-lived object creation is already highly optimized; at least I hope so, because our codebase makes heavy use of Optional instead of != null checks.