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

Unwanted function call for std::map::operator[] #866

Open
ankurhero opened this issue Jun 30, 2021 · 1 comment
Open

Unwanted function call for std::map::operator[] #866

ankurhero opened this issue Jun 30, 2021 · 1 comment

Comments

@ankurhero
Copy link

m_map[key] = std::make_pair(value, j);

Since i is a valid iterator, we can replace this call with.
m_map[key] = std::make_pair(value, j);

with

i->second = std::make_pair(value, j);

avoiding the second map search.

@chetanpandey1266
Copy link

I don't think this will work as iterator is not passing to the location corresponding to key but to a random position ( map.end() ).

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

No branches or pull requests

2 participants