Optimize Mongo::Connection#send_message_on_socket: don't slice the input when not necessary.
This commit is contained in:
parent
87e6d578c1
commit
6316c939d5
|
@ -845,12 +845,15 @@ module Mongo
|
|||
# @return [Integer] number of bytes sent
|
||||
def send_message_on_socket(packed_message, socket)
|
||||
begin
|
||||
total_bytes_sent = 0
|
||||
total_bytes_sent = socket.send(packed_message, 0)
|
||||
if total_bytes_sent != packed_message.size
|
||||
packed_message.slice!(0, total_bytes_sent)
|
||||
while packed_message.size > 0
|
||||
byte_sent = socket.send(packed_message, 0)
|
||||
total_bytes_sent += byte_sent
|
||||
packed_message.slice!(0, byte_sent)
|
||||
end
|
||||
end
|
||||
total_bytes_sent
|
||||
rescue => ex
|
||||
close
|
||||
|
|
Loading…
Reference in New Issue