`std::map` has `find` function that should be faster than iterating over all the entries and also handles the empty map case, so you don't need to handle it separately.