Skip to content

Commit 12c1568

Browse files
removing unneeded changes
1 parent 47c4bea commit 12c1568

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

lib/mongo/srv/resolver.rb

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ def timeout
6161
options[:timeout] || Monitor::DEFAULT_TIMEOUT
6262
end
6363

64-
# Fisher-Yates shuffling algorithm helper
65-
# @param [ Array ] array The array to shuffle
66-
# @return [ Array ] The shuffled array
67-
# @api private
68-
def shuffle(array)
69-
a = array.dup
70-
n = a.length
71-
(n - 1).downto(1) do |i|
72-
j = rand(i + 1)
73-
a[i], a[j] = a[j], a[i]
74-
end
75-
a
76-
end
77-
7864
# Obtains all of the SRV records for a given hostname. If a srv_max_hosts
7965
# is specified and it is greater than 0, return maximum srv_max_hosts records.
8066
#
@@ -128,7 +114,7 @@ def get_records(hostname, srv_service_name=nil, srv_max_hosts=nil)
128114

129115
# if srv_max_hosts is in [1, #addresses)
130116
if (1...result.address_strs.length).include? srv_max_hosts
131-
sampled_records = shuffle(resources).first(srv_max_hosts)
117+
sampled_records = resources.shuffle.first(srv_max_hosts)
132118
result = Srv::Result.new(hostname)
133119
sampled_records.each { |record| result.add_record(record) }
134120
end

0 commit comments

Comments
 (0)