refactor: omit redundant map searches (#19929)

* refactor: don't walk maps twice to remove elements

* refactor: don't walk maps twice to read elements

* refactor: don't walk maps twice to insert elements

* refactor: don't walk map 3x on UvTaskRunner timeout

* refactor: more don't-walk-maps-twice cleanup

* fixup! refactor: don't walk maps twice to insert elements

* refactor: don't walk containers twice when erasing

* refactor: omit excess lookups in RemoteObjectFreer
This commit is contained in:
Charles Kerr 2019-08-28 09:39:21 -05:00 committed by GitHub
parent 27ce6a9cd3
commit 987300c97a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 88 additions and 86 deletions

View file

@ -25,11 +25,9 @@ void AtomMenuModel::SetToolTip(int index, const base::string16& toolTip) {
}
base::string16 AtomMenuModel::GetToolTipAt(int index) {
int command_id = GetCommandIdAt(index);
if (base::Contains(toolTips_, command_id))
return toolTips_[command_id];
else
return base::string16();
const int command_id = GetCommandIdAt(index);
const auto iter = toolTips_.find(command_id);
return iter == std::end(toolTips_) ? base::string16() : iter->second;
}
void AtomMenuModel::SetRole(int index, const base::string16& role) {
@ -38,11 +36,9 @@ void AtomMenuModel::SetRole(int index, const base::string16& role) {
}
base::string16 AtomMenuModel::GetRoleAt(int index) {
int command_id = GetCommandIdAt(index);
if (base::Contains(roles_, command_id))
return roles_[command_id];
else
return base::string16();
const int command_id = GetCommandIdAt(index);
const auto iter = roles_.find(command_id);
return iter == std::end(roles_) ? base::string16() : iter->second;
}
bool AtomMenuModel::GetAcceleratorAtWithParams(