green-code-initiative / ecoCode

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

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

Closed Samdespion closed 3 months ago

Samdespion commented 3 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 3 months ago

PR accepted and updated like follow :