topology: use std::erase_if on std::map instead of ad-hoc loop

There is std::erase_if since c++20. We can use it here.

Message-Id: <20221228144944.3299711-6-gleb@scylladb.com>
This commit is contained in:
Gleb Natapov
2022-12-28 16:49:17 +02:00
committed by Avi Kivity
parent 84eb5924ac
commit 6f104982e1

View File

@@ -596,14 +596,7 @@ void token_metadata_impl::add_bootstrap_tokens(std::unordered_set<token> tokens,
}
}
// Unfortunately, std::remove_if does not work with std::map
for (auto it = _bootstrap_tokens.begin(); it != _bootstrap_tokens.end();) {
if ((*it).second == endpoint) {
it = _bootstrap_tokens.erase(it);
} else {
it++;
}
}
std::erase_if(_bootstrap_tokens, [endpoint] (const std::pair<token, inet_address>& n) { return n.second == endpoint; });
for (auto t : tokens) {
_bootstrap_tokens[t] = endpoint;