Closed roookeee closed 5 years ago
Still unsure if I will stick with the nullsafe()
approach. Will reconsider the name too
The shown code in #21 looks like this atm and performs nearly twice as fast for a prototype implementation of datus I did for this benchmark suite :
.from(Order::getCustomer).nullsafe()
.map(Customer::getBillingAddress)
.map(Address::getCity)
.into(OrderDTO::setBillingCity)
The performance gains are expected as given()
is quite heavy compared to a simple null propagation. We are only ~4-5x slower than a hand-rolled implementation now :)
Switched to a SafetyMode
enum instead of a boolean flag to be extendable in the future without breaking compatability as fast. It's also more descriptive
I feel like this PR is done :)
An implementation for #21:
Objects::nonNull
is not a good candidate after this PR)