Optimize Mongo::Connection#read_documents by using raw string operations and unpack() instead of the slower ByteBuffer.
This commit is contained in:
parent
1c25541492
commit
2291a59fcc
|
@ -786,13 +786,10 @@ module Mongo
|
||||||
docs = []
|
docs = []
|
||||||
number_remaining = number_received
|
number_remaining = number_received
|
||||||
while number_remaining > 0 do
|
while number_remaining > 0 do
|
||||||
buf = BSON::ByteBuffer.new
|
buf = receive_message_on_socket(4, sock)
|
||||||
buf.put_array(receive_message_on_socket(4, sock).unpack("C*"))
|
size = buf.unpack('V')[0]
|
||||||
buf.rewind
|
buf << receive_message_on_socket(size - 4, sock)
|
||||||
size = buf.get_int
|
|
||||||
buf.put_array(receive_message_on_socket(size - 4, sock).unpack("C*"), 4)
|
|
||||||
number_remaining -= 1
|
number_remaining -= 1
|
||||||
buf.rewind
|
|
||||||
docs << BSON::BSON_CODER.deserialize(buf)
|
docs << BSON::BSON_CODER.deserialize(buf)
|
||||||
end
|
end
|
||||||
[docs, number_received, cursor_id]
|
[docs, number_received, cursor_id]
|
||||||
|
|
Loading…
Reference in New Issue