diff options
| author | Sintendo <3380580+Sintendo@users.noreply.github.com> | 2025-07-06 08:41:12 +0200 |
|---|---|---|
| committer | Sintendo <3380580+Sintendo@users.noreply.github.com> | 2025-07-08 06:53:42 +0200 |
| commit | f2392e4048ce977bad2227d08f3a042526f7c4da (patch) | |
| tree | 1ff5cd55011aa8503f504eefc57e49a7c35985a8 /Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp | |
| parent | a5e85caf0af66fec07b476718a69519b06e6a69f (diff) | |
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.
Diffstat (limited to 'Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp index 0677666416..621e0113c7 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp @@ -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); |
