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,11 +845,14 @@ module Mongo
|
||||||
# @return [Integer] number of bytes sent
|
# @return [Integer] number of bytes sent
|
||||||
def send_message_on_socket(packed_message, socket)
|
def send_message_on_socket(packed_message, socket)
|
||||||
begin
|
begin
|
||||||
total_bytes_sent = 0
|
total_bytes_sent = socket.send(packed_message, 0)
|
||||||
while packed_message.size > 0
|
if total_bytes_sent != packed_message.size
|
||||||
byte_sent = socket.send(packed_message, 0)
|
packed_message.slice!(0, total_bytes_sent)
|
||||||
total_bytes_sent += byte_sent
|
while packed_message.size > 0
|
||||||
packed_message.slice!(0, byte_sent)
|
byte_sent = socket.send(packed_message, 0)
|
||||||
|
total_bytes_sent += byte_sent
|
||||||
|
packed_message.slice!(0, byte_sent)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
total_bytes_sent
|
total_bytes_sent
|
||||||
rescue => ex
|
rescue => ex
|
||||||
|
|
Loading…
Reference in New Issue