refactor: unify container presence checks - non-trivial counts

The changes made here were:

| From              | To               |
|-------------------|------------------|
| `m.count(k) == 1` | `m.contains(k)`  |
| `m.count(k) == 0` | `!m.contains(k)` |
| `m.count(k) != 1` | `!m.contains(k)` |
| `m.count(k) < 1`  | `!m.contains(k)` |

* `mapInfo` is instance of `std::unordered_map` and can only contain 0 or 1 value for a given key;
* similarly, `g_enabled_filter_types` and `setClientRules` are both `std::set` instances;
* lastly, while `mapTxSpends` is `std::unordered_multimap` that could potentially hold multiple values, having a size less than 1 means that the value is missing.

`QMap<WalletModel*, WalletView*> mapWalletViews` values were also migrated manually.

Co-authored-by: pablomartin4btc <pablomartin4btc@gmail.com>
Co-authored-by: fanquake <fanquake@gmail.com>
This commit is contained in:
committed 2025-12-03 13:37:17 +01:00
1 parent 039307554e
commit d9319b06cf
5 files changed
+10 -10

No files matched your search

+3 -3
View File
@@ -70,7 +70,7 @@ bool WalletFrame::addView(WalletView* walletView)
{
if (!clientModel) return false;
if (mapWalletViews.count(walletView->getWalletModel()) > 0) return false;
if (mapWalletViews.contains(walletView->getWalletModel())) return false;
walletView->setClientModel(clientModel);
walletView->showOutOfSyncWarning(bOutOfSync);
@@ -90,7 +90,7 @@ bool WalletFrame::addView(WalletView* walletView)
void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
{
if (mapWalletViews.count(wallet_model) == 0) return;
if (!mapWalletViews.contains(wallet_model)) return;
// Stop the effect of hidden widgets on the size hint of the shown one in QStackedWidget.
WalletView* view_about_to_hide = currentWalletView();
@@ -116,7 +116,7 @@ void WalletFrame::setCurrentWallet(WalletModel* wallet_model)
void WalletFrame::removeWallet(WalletModel* wallet_model)
{
if (mapWalletViews.count(wallet_model) == 0) return;
if (!mapWalletViews.contains(wallet_model)) return;
WalletView *walletView = mapWalletViews.take(wallet_model);
walletStack->removeWidget(walletView);