Skip to content

gcore: Use initializer list for min or max of more than 2 numbers. #12850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2025

Conversation

schwehr
Copy link
Member

@schwehr schwehr commented Aug 2, 2025

Why?

  • Slightly more readable with the form std::min({a, b, c, ...}
  • Slightly better performance for non-optimized builds

An example to play with: https://godbolt.org/z/sKfTMz6GE

Spotted reviewing ac95cad / #12814

It's a C++11 feature, so safe to do: https://en.cppreference.com/w/cpp/algorithm/min.html

@schwehr schwehr requested review from rouault and dbaston August 2, 2025 16:22
@schwehr
Copy link
Member Author

schwehr commented Aug 2, 2025

Doh! Forgot to run pre-commit

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 71.118% (-0.003%) from 71.121%
when pulling 821be0f on schwehr:min-max-3plus-args
into 15f3e47 on OSGeo:master.

@schwehr schwehr merged commit 154fa0f into OSGeo:master Aug 2, 2025
38 checks passed
@schwehr schwehr deleted the min-max-3plus-args branch August 2, 2025 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants