-
Notifications
You must be signed in to change notification settings - Fork 10k
Modernize some for loops and fix some signed/unsigned issues #4438
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
Conversation
Signed-off-by: Stefan Weil <[email protected]>
Signed-off-by: Stefan Weil <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some loops can be further improved with algorithms/ranges, but not insisting on changes
unsigned s = 0; | ||
for (s = 0; s < allowed_scripts_->size(); ++s) { | ||
if ((*allowed_scripts_)[s] == choice_script) { | ||
for (auto script : *allowed_scripts_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be if (std::ranges::find(*allowed_scripts_, choice_script) != allowed_scripts_->end()) ...
const auto shape_id = results[r].shape_id; | ||
size_t r = 0; | ||
for (const auto &result : results) { | ||
const auto shape_id = result.shape_id; | ||
const Shape &shape = shape_table.GetShape(shape_id); | ||
if (shape.ContainsUnichar(unichar_id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (shape_table.GetShape(result.shape_id).ContainsUnichar(unichar_id)) {
also can be put inside std::ranges::find_if()
for (unsigned r = 0; r < results.size(); ++r) { | ||
if (results[r].unichar_id == unichar_id) { | ||
size_t r = 0; | ||
for (const auto &result : results) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::ranges::find
Thanks for these suggestions which we can consider in later commits. |
No description provided.