green-code-initiative / ecoCode

Reduce the environmental footprint of your software programs with SonarQube
https://ecocode.io
GNU General Public License v3.0
165 stars 78 forks source link

[Challenge 2024 - HAFNIUM] EC1369 Use orElseGet instead of orElse #323

Closed Samdespion closed 5 months ago

Samdespion commented 6 months ago

Parameter of orElse() is evaluated, even when having a non-empty Optional. orElseGet supplier method passed as an argument is only executed when an Optional value isn’t present :

https://github.com/green-code-initiative/ecoCode-challenge/issues/77

dedece35 commented 5 months ago

PR accepted and updated like follow :