mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-10-04 23:29:18 +00:00
Avoid map/set double lookups
Fix some common anti-patterns with these data structures. - You can dereference the iterator returned by `find` to access the underlying value directly, without an extra `operator[]`/`at`. - Rather than checking for an element before insertion/deletion, you can just do the operation and if needed check the return value to determine if the insertion/deletion succeeded.
This commit is contained in:
parent
a5e85caf0a
commit
f2392e4048
15 changed files with 69 additions and 74 deletions
|
@ -655,8 +655,9 @@ void NetPlayDialog::UpdateGUI()
|
|||
|
||||
auto* name_item = new QTableWidgetItem(QString::fromStdString(p->name));
|
||||
name_item->setToolTip(name_item->text());
|
||||
const auto& status_info = player_status.contains(p->game_status) ?
|
||||
player_status.at(p->game_status) :
|
||||
const auto it = player_status.find(p->game_status);
|
||||
const auto& status_info = it != player_status.end() ?
|
||||
it->second :
|
||||
std::make_pair(QStringLiteral("?"), QStringLiteral("?"));
|
||||
auto* status_item = new QTableWidgetItem(status_info.first);
|
||||
status_item->setToolTip(status_info.second);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue