effective_replication_map: get_range_addresses: use the precalculated replication_map

There is no need to call get_natural_endpoints for every token
in sorted_tokens order, since we can just get the precalculated
per-token endpoints already in the _replication_map member.

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2022-07-10 17:58:43 +03:00
parent 1d4aea4441
commit 6794e15163

View File

@@ -260,9 +260,8 @@ std::unordered_map<dht::token_range, inet_address_vector_replica_set>
effective_replication_map::get_range_addresses() const {
const token_metadata& tm = *_tmptr;
std::unordered_map<dht::token_range, inet_address_vector_replica_set> ret;
for (auto& t : tm.sorted_tokens()) {
for (const auto& [t, eps] : _replication_map) {
dht::token_range_vector ranges = tm.get_primary_ranges_for(t);
auto eps = get_natural_endpoints(t);
for (auto& r : ranges) {
ret.emplace(r, eps);
}