Skip to content

Commit ed59464

Browse files
committed
perf: faster extract_hash_tag (again)
1 parent 4f0cd91 commit ed59464

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/redis_client/cluster/command.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ def determine_optional_key_position(command, option_name) # rubocop:disable Metr
106106
# @see https://redis.io/topics/cluster-spec#keys-hash-tags Keys hash tags
107107
def extract_hash_tag(key)
108108
key = key.to_s
109+
109110
s = key.index(LEFT_BRACKET)
110-
e = key.index(RIGHT_BRACKET, s.to_i + 1)
111-
112-
return EMPTY_STRING if s.nil? || e.nil?
111+
return EMPTY_STRING if s.nil?
112+
113+
e = key.index(RIGHT_BRACKET, s + 1)
114+
return EMPTY_STRING if e.nil?
113115

114116
key[s + 1..e - 1]
115117
end

0 commit comments

Comments
 (0)