Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cad1e91

Browse files
mykauldkropachev
authored andcommitted
(minor improvement): small refactoring in SimpleStrategy's make_token_replica_map()
While trying to look at some random (flaky?) test (#510 (comment) ) I saw some (minor) improvements that can be made to SimpleStrategy's make_token_replica_map(): Specifically - remove some redundant len() calls to outside the loop(s) Probably very very minor improvement, perhaps in a large cluster it'll be noticable - but no one should use SimpleStrategy anyway! Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>
1 parent 1262d43 commit cad1e91

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎cassandra/metadata.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,11 @@ def __init__(self, options_map):
569569

570570
def make_token_replica_map(self, token_to_host_owner, ring):
571571
replica_map = {}
572-
for i in range(len(ring)):
572+
ring_len = len(ring)
573+
for i in range(ring_len):
573574
j, hosts = 0, list()
574-
while len(hosts) < self.replication_factor and j < len(ring):
575-
token = ring[(i + j) % len(ring)]
575+
while len(hosts) < self.replication_factor and j < ring_len:
576+
token = ring[(i + j) % ring_len]
576577
host = token_to_host_owner[token]
577578
if host not in hosts:
578579
hosts.append(host)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /