Chromium Code Reviews| Index: ui/base/models/menu_model.cc |
| diff --git a/ui/base/models/menu_model.cc b/ui/base/models/menu_model.cc |
| index c7defd9062746ae1c3f0cd7ebb2ac4ec05f1400d..8c76944768283b3582984b879b2c81ac0101e80c 100644 |
| --- a/ui/base/models/menu_model.cc |
| +++ b/ui/base/models/menu_model.cc |
| @@ -16,17 +16,18 @@ bool MenuModel::IsVisibleAt(int index) const { |
| bool MenuModel::GetModelAndIndexForCommandId(int command_id, |
| MenuModel** model, int* index) { |
| - int item_count = (*model)->GetItemCount(); |
| + const int item_count = (*model)->GetItemCount(); |
| for (int i = 0; i < item_count; ++i) { |
| - if ((*model)->GetTypeAt(i) == TYPE_SUBMENU) { |
| - MenuModel* submenu_model = (*model)->GetSubmenuModelAt(i); |
| + const int candidate_index = i + (*model)->GetFirstItemIndex(NULL); |
|
sky
2011/05/25 15:41:12
Move this call outside the loop.
rhashimoto
2011/05/25 16:24:37
Done.
|
| + if ((*model)->GetTypeAt(candidate_index) == TYPE_SUBMENU) { |
| + MenuModel* submenu_model = (*model)->GetSubmenuModelAt(candidate_index); |
| if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) { |
| *model = submenu_model; |
| return true; |
| } |
| } |
| - if ((*model)->GetCommandIdAt(i) == command_id) { |
| - *index = i; |
| + if ((*model)->GetCommandIdAt(candidate_index) == command_id) { |
| + *index = candidate_index; |
| return true; |
| } |
| } |