Skip to content

Commit f440440

Browse files
authored
refactor: use Array#index instead of Enumerable#each_with_index (#424)
1 parent 4d0656a commit f440440

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/redis_client/cluster/command.rb

+2-5
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,8 @@ def determine_first_key_position(command) # rubocop:disable Metrics/CyclomaticCo
122122
end
123123

124124
def determine_optional_key_position(command, option_name)
125-
command.each_with_index do |e, i|
126-
return i + 1 if e.to_s.casecmp(option_name).zero?
127-
end
128-
129-
0
125+
i = command.index { |v| v.to_s.casecmp(option_name).zero? }
126+
i.nil? ? 0 : i + 1
130127
end
131128
end
132129
end

0 commit comments

Comments
 (0)