I absolutely love the Java 8 features, because of readability, but I am concerned about performance degrading that they might cause. While it probably doesn't affect the application speed in the long run due to JIT, it might affect memory usage, which is one of my primary concerns. IntelliJ IDEA provides the option to convert Stream API usages to loops (for single usage). Is there a way to inline all these features every time I build my project?
For example, if I use find("my-record").ifPresent(records::add)
, I would expect these changes: signature of Optional<Record> find(String)
to be converted to (Nullable) Record find(String)
and the method call to be converted to a null-check.
Note: I know that there are tons of subtle differences between, say, streams and loops, but I design my code not to rely on details of implementation.