refactor: unify container presence checks - trivial counts

The changes made here were:

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

The commit contains the trivial, mechanical refactors where it doesn't matter if the container can have multiple elements or not

Co-authored-by: Jan B <608446+janb84@users.noreply.github.com>
This commit is contained in:
Lőrinc
2025-08-14 18:29:30 -07:00
parent 8bb9219b63
commit 039307554e
56 changed files with 163 additions and 163 deletions

View File

@@ -687,7 +687,7 @@ struct SmartInfo
while (true) {
size_t set_size = useful_types.size();
for (const auto& [type, recipes] : table) {
if (useful_types.count(type) != 0) {
if (useful_types.contains(type)) {
for (const auto& [_, subtypes] : recipes) {
for (auto subtype : subtypes) useful_types.insert(subtype);
}
@@ -697,7 +697,7 @@ struct SmartInfo
}
// Remove all rules that construct uninteresting types.
for (auto type_it = table.begin(); type_it != table.end();) {
if (useful_types.count(type_it->first) == 0) {
if (!useful_types.contains(type_it->first)) {
type_it = table.erase(type_it);
} else {
++type_it;
@@ -710,7 +710,7 @@ struct SmartInfo
* because they can only be constructed using recipes that involve otherwise
* non-constructible types, or because they require infinite recursion. */
std::set<Type> constructible_types{};
auto known_constructible = [&](Type type) { return constructible_types.count(type) != 0; };
auto known_constructible = [&](Type type) { return constructible_types.contains(type); };
// Find the transitive closure by adding types until the set of types does not change.
while (true) {
size_t set_size = constructible_types.size();
@@ -1177,13 +1177,13 @@ void TestNode(const MsCtx script_ctx, const NodeRef& node, FuzzedDataProvider& p
case Fragment::AFTER:
return node.k & 1;
case Fragment::SHA256:
return TEST_DATA.sha256_preimages.count(node.data);
return TEST_DATA.sha256_preimages.contains(node.data);
case Fragment::HASH256:
return TEST_DATA.hash256_preimages.count(node.data);
return TEST_DATA.hash256_preimages.contains(node.data);
case Fragment::RIPEMD160:
return TEST_DATA.ripemd160_preimages.count(node.data);
return TEST_DATA.ripemd160_preimages.contains(node.data);
case Fragment::HASH160:
return TEST_DATA.hash160_preimages.count(node.data);
return TEST_DATA.hash160_preimages.contains(node.data);
default:
assert(false);
}