Skip to content

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

Merged
merged 2 commits into from
Jul 6, 2025
Merged

Conversation

stweil
Copy link
Member

@stweil stweil commented Jul 6, 2025

No description provided.

Copy link
Contributor

@egorpugin egorpugin left a 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_) {
Copy link
Contributor

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)) {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::ranges::find

@stweil stweil merged commit d3e50cf into main Jul 6, 2025
6 checks passed
@stweil
Copy link
Member Author

stweil commented Jul 6, 2025

Some loops can be further improved with algorithms/ranges, but not insisting on changes

Thanks for these suggestions which we can consider in later commits.

@stweil stweil deleted the modernize branch July 6, 2025 20:04
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.

2 participants