commit | 53d615a6286d1ca1fdca7dc84eee42b4e63fc70d | [log] [tgz] |
---|---|---|
author | Nasser Grainawi <nasser.grainawi@linaro.org> | Wed Apr 10 11:22:53 2024 -0600 |
committer | Nasser Grainawi <nasser.grainawi@linaro.org> | Wed Apr 10 20:20:17 2024 +0000 |
tree | 66caa91bf43a431221dc930661469c0a75dd2b59 | |
parent | c67b626687e3bbf8296c82f93fe02003f79c749a [diff] |
Avoid work in Optional.orElse() calls Any code inside the orElse() will always be called, even if the result isn't used because the optional is present. This is wasteful at a minimum and can be actively harmful (as seen in [1]) because of side effects or performance impacts. Fix that by replacing all orElse() calls that create new instances or do non-constant work with a call to orElseGet(). It would be nice if there were an ErrorProne checker for this, but one doesn't exist yet. [1] https://gerrit-review.googlesource.com/c/gerrit/+/417915/comment/0ea287cd_bfecb7f2/ Release-Notes: skip Change-Id: I2d3d59da88cd04a2e589b7255fc0877719a57432
Gerrit web-based plugin manager.
To enable this plugin, please look at the configuration guide