You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementation of at would be more efficient if you got rid of the first call to contains_key and simply used find directly. You call contains_key to check if something is in the map (doing a map lookup in the process) then, if so, immediately call at on the underlying map (doing a redundant map lookup) to access the value.
insert_or_assign, move, and move_only all have the same problem. move_and_erase is even worse - you either call at on yourself or operator[] on the underlying map, so you do a wasted lookup in BOTH branches.
Comment from reddit
Implementation of at would be more efficient if you got rid of the first call to contains_key and simply used find directly. You call contains_key to check if something is in the map (doing a map lookup in the process) then, if so, immediately call at on the underlying map (doing a redundant map lookup) to access the value.
insert_or_assign, move, and move_only all have the same problem. move_and_erase is even worse - you either call at on yourself or operator[] on the underlying map, so you do a wasted lookup in BOTH branches.
https://www.reddit.com/r/cpp/comments/m9uwaq/releasing_lazy_map_c_library/grpmxlp?utm_source=share&utm_medium=web2x&context=3
The text was updated successfully, but these errors were encountered: