refactor: unify container presence checks - find

The changes made here were:

| From                   | To               |
|------------------------|------------------|
| `m.find(k) == m.end()` | `!m.contains(k)` |
| `m.find(k) != m.end()` | `m.contains(k)`  |
This commit is contained in:
Lőrinc committed 2025-12-03 13:31:11 +01:00
1 parent 6581ac5d9f
commit 8bb9219b63
9 files changed
+11 -11

No files matched your search

+1 -1
View File
@@ -1129,7 +1129,7 @@ static void ParseGetInfoResult(UniValue& result)
const std::string proxy = network["proxy"].getValStr();
if (proxy.empty()) continue;
// Add proxy to ordered_proxy if has not been processed
if (proxy_networks.find(proxy) == proxy_networks.end()) ordered_proxies.push_back(proxy);
if (!proxy_networks.contains(proxy)) ordered_proxies.push_back(proxy);
proxy_networks[proxy].push_back(network["name"].getValStr());
}
+1 -1
View File
@@ -164,7 +164,7 @@ std::list<SectionInfo> ArgsManager::GetUnrecognizedSections() const
LOCK(cs_args);
std::list<SectionInfo> unrecognized = m_config_sections;
unrecognized.remove_if([](const SectionInfo& appeared){ return available_sections.find(appeared.m_name) != available_sections.end(); });
unrecognized.remove_if([](const SectionInfo& appeared){ return available_sections.contains(appeared.m_name); });
return unrecognized;
}
+1 -1
View File
@@ -240,7 +240,7 @@ void MiniMiner::SanityCheck() const
entry->second.GetModFeesWithAncestors() >= entry->second.GetModifiedFee();}));
// None of the entries should be to-be-replaced transactions
Assume(std::all_of(m_to_be_replaced.begin(), m_to_be_replaced.end(),
[&](const auto& txid){return m_entries_by_txid.find(txid) == m_entries_by_txid.end();}));
[&](const auto& txid){ return !m_entries_by_txid.contains(txid); }));
}
void MiniMiner::BuildMockTemplate(std::optional<CFeeRate> target_feerate)
+1 -1
View File
@@ -77,7 +77,7 @@ public:
// Read the version
uint16_t version;
s >> version;
if (m_supported_versions.find(version) == m_supported_versions.end()) {
if (!m_supported_versions.contains(version)) {
throw std::ios_base::failure(strprintf("Version of snapshot %s does not match any of the supported versions.", version));
}
+2 -2
View File
@@ -26,7 +26,7 @@ bool IsTopoSortedPackage(const Package& txns, std::unordered_set<Txid, SaltedTxi
// than its child.
for (const auto& tx : txns) {
for (const auto& input : tx->vin) {
if (later_txids.find(input.prevout.hash) != later_txids.end()) {
if (later_txids.contains(input.prevout.hash)) {
// The parent is a subsequent transaction in the package.
return false;
}
@@ -62,7 +62,7 @@ bool IsConsistentPackage(const Package& txns)
return false;
}
for (const auto& input : tx->vin) {
if (inputs_seen.find(input.prevout) != inputs_seen.end()) {
if (inputs_seen.contains(input.prevout)) {
// This input is also present in another tx in the package.
return false;
}
+1 -1
View File
@@ -1172,7 +1172,7 @@ UniValue RPCResult::MatchesType(const UniValue& result) const
std::map<std::string, UniValue> result_obj;
result.getObjMap(result_obj);
for (const auto& result_entry : result_obj) {
if (doc_keys.find(result_entry.first) == doc_keys.end()) {
if (!doc_keys.contains(result_entry.first)) {
errors.pushKV(result_entry.first, "key returned that was not in doc");
}
}
+1 -1
View File
@@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(util_threadnames_test_rename_threaded)
// Names "test_thread.[n]" should exist for n = [0, 99]
for (int i = 0; i < 100; ++i) {
BOOST_CHECK(names.find(TEST_THREAD_NAME_BASE + ToString(i)) != names.end());
BOOST_CHECK(names.contains(TEST_THREAD_NAME_BASE + ToString(i)));
}
}
+1 -1
View File
@@ -988,7 +988,7 @@ util::Result<std::pair<std::vector<FeeFrac>, std::vector<FeeFrac>>> CTxMemPool::
CTxMemPool::ChangeSet::TxHandle CTxMemPool::ChangeSet::StageAddition(const CTransactionRef& tx, const CAmount fee, int64_t time, unsigned int entry_height, uint64_t entry_sequence, bool spends_coinbase, int64_t sigops_cost, LockPoints lp)
{
LOCK(m_pool->cs);
Assume(m_to_add.find(tx->GetHash()) == m_to_add.end());
Assume(!m_to_add.contains(tx->GetHash()));
Assume(!m_dependencies_processed);
// We need to process dependencies after adding a new transaction.
+2 -2
View File
@@ -1107,8 +1107,8 @@ bool DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB(WalletBatch& batch, const
assert(!m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS));
// Check if provided key already exists
if (m_map_keys.find(pubkey.GetID()) != m_map_keys.end() ||
m_map_crypted_keys.find(pubkey.GetID()) != m_map_crypted_keys.end()) {
if (m_map_keys.contains(pubkey.GetID()) ||
m_map_crypted_keys.contains(pubkey.GetID())) {
return true;
}