Skip to content
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

Simplify for loops #2082

Merged
merged 3 commits into from
Dec 13, 2024
Merged

Simplify for loops #2082

merged 3 commits into from
Dec 13, 2024

Conversation

fwesselm
Copy link
Contributor

I accidentally found two for loops in src/simplex/HEkkDualRow.cpp that could be rewritten as ranged-based for loops, which would simplify the code, I think.

Copy link
Member

@jajhall jajhall left a comment

Choose a reason for hiding this comment

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

I've never used iterators, so can't comment on the correctness of the change. What's the gain in making the change?

Copy link
Member

@jajhall jajhall left a comment

Choose a reason for hiding this comment

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

Since both changes occur in lines that are heavily used, any errors would manifest themselves immediately.

I still wonder what's gained by changing the code in this way

@fwesselm
Copy link
Contributor Author

Since both changes occur in lines that are heavily used, any errors would manifest themselves immediately.

I still wonder what's gained by changing the code in this way

Ranged-based for loops were introduced with C++11 (and are used in the presolve code, for example).

The code here iterates over the entire std::set<HighsInt> freeList. I think this change makes the code syntactically simpler and easier to read and understand. Of course, there won't be performance gains.

@jajhall jajhall merged commit 1e3fbe5 into ERGO-Code:latest Dec 13, 2024
103 of 104 checks passed
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