-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
iterator cleanup in several places #2164
Conversation
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.
Looks good in general but it feels a bit awkward to see iterators-like names it
/itOutpointLock
/etc inside loop blocks. Let's clean this up pls e.g. s/itOutpointLock/outpointLock/
etc.
You're probably right. What would you suggest I use for a Or are you only suggesting this for the longer |
For simple cases like that (literally two rows of code) |
Ok, I believe I have addressed the naming issues. I have also cleaned up a few more places in the code where range-based |
You can't do this
It's going to segfault. |
@UdjinM6 Works fine in my test. Code: https://gitlab.com/nmarley/cpptest/blob/master/range-for-modify.cpp Output: https://gist.github.com/nmarley/c28de321bd15d1205900b1cf9d595d2e |
|
@UdjinM6 Sorry, should be public now. And you're right, looks like this code was "working" because of some internal ordering of keys. Once I tried deleting element I will go back and refactor (or revert) these. I was hoping to get rid of all the incrementing iterator |
Well, if that was the goal, you could probably try smth like:
EDIT: or if you REEEALLY want to use
:) |
The problem with the approach above is that this way you always create a copy, even if you don't need it, while with EDIT: however for small maps the overhead is probably negligible. |
Well, my idea was actually to invert the if / else condition such that I can |
I've reverted changes where I made the false assuption that a container being iterated over could be modified using range-based for, which isn't the case. Also rebased onto the latest |
Just had one question on the rationale for edit: I fast-forwarded my branch tip to include your commits directly. |
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.
ACK
* iterator cleanup in Dash-specific code * const * *Pair/pair * it++ -> ++it
Please see individual commits. A few notes:
auto
and range-basedfor