…te counters in C instead of Ruby.
…_discard_message_on_socket: avoid creating initial input buffer up front so that IO#read only needs to allocate the buffer once.
…put when not necessary.
…ly instead of using ByteBuffer.
…ngoDB::Connection #receive_header and #last_error_message: usage strings as much as possible instead of byte arrays, otherwise performance really suffers.
…em over and over.
…ing operations and unpack() instead of the slower ByteBuffer.
…ons and unpack() instead of the slower ByteBuffer.
The set in there is unnecessary. Use the hash itself as "set". This makes BSON::OrderedHash 148% faster on Ruby 1.8.
…ere 1 socket.read() operation receives all requested data. Also fix some Ruby 1.9 encoding issues in that function while we're at it.
`each_with_object` is a Ruby 1.9 method, here re-implemented in core_ext.rb in case it's missing (for older Ruby versions). Using `returning` is bad in combination with Ruby on Rails because each usage of the method will emit a Rails deprecation warning. This might be considered an Active Support bug, but it's better to avoid using `returning` altogether and use `tap` from Ruby 1.8.7, also re-implemented here in case it's missing. Since existing usages or `returning` were better suited for `each_with_object` than `tap`, they were rewritten using the former instead.
… as a binary String instead of an array. This dramatically improves the performance of BSON::ByteBuffer.new(a_string). On Ruby 1.9.2 it is about 130 times faster.
Results in a pretty significant performance improvement. Many thanks to Matt Taylor for noticing the unusual glut of calls to ObjectId#to_s. See here: http://unhalting.com/?p=18