Skip to content

Commit

Permalink
remove pack/unpack overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
christophsturm authored and bcg committed Sep 13, 2011
1 parent f806c48 commit 6932aa6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/em-mongo/connection.rb
Expand Up @@ -154,7 +154,7 @@ def peek_size(buffer)

def receive_data(data)

@buffer.append!(BSON::ByteBuffer.new(data.unpack('C*')))
@buffer.append!(data)

@buffer.rewind
while message_received?(@buffer)
Expand All @@ -165,7 +165,7 @@ def receive_data(data)

if @buffer.more?
remaining_bytes= @buffer.size-@buffer.position
@buffer = BSON::ByteBuffer.new(@buffer.get(remaining_bytes))
@buffer = BSON::ByteBuffer.new(@buffer.to_s[@buffer.position,remaining_bytes])
@buffer.rewind
else
@buffer.clear
Expand Down

0 comments on commit 6932aa6

Please sign in to comment.