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
osd/OSD.h: change iterator to const_iterator #9387
Conversation
@@ -1453,7 +1453,7 @@ class OSD : public Dispatcher, | |||
|
|||
void clear_waiting_sessions() { | |||
Mutex::Locker l(session_waiting_lock); | |||
for (map<spg_t, set<Session*> >::iterator i = | |||
for (map<spg_t, set<Session*> >::const_iterator i = |
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.
this creates a const_iterator
from an iterator
. which incurs the cost of calling a copy ctor. if you want to make sure that we are using the const_iterator
for reading containers. maybe you could use auto
, session_waiting_for_pg.cbegin()
, session_waiting_for_pg.cend()
instead?
Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
c5861d5
to
0b4df52
Compare
@tchaikov |
yes, it creates an
i am not sure about this though. |
I wrote this program to check:
stiopa@stiopa-desktop|~/temp/constiter_opt stiopa@stiopa-desktop|~/temp/constiter_opt
I don't have much experience with assembly code, so this test might be completely wrong, but if it's not then the both functions look the same? |
@stiopaa1 you are quite right! |
lgtm |
Signed-off-by: Michal Jarzabek stiopa@gmail.com