*** /before/lib/ruby/1.9.1/net/protocol.rb 2012-05-15 11:26:54.000000000 -0700 --- /after/lib/ruby/1.9.1/net/protocol.rb 2012-05-15 13:19:09.000000000 -0700 *************** *** 84,100 **** def read(len, dest = '', ignore_eof = false) LOG "reading #{len} bytes..." read_bytes = 0 begin ! while read_bytes + @rbuf.size < len ! dest << (s = rbuf_consume(@rbuf.size)) ! read_bytes += s.size rbuf_fill end dest << (s = rbuf_consume(len - read_bytes)) ! read_bytes += s.size rescue EOFError raise unless ignore_eof end LOG "read #{read_bytes} bytes" dest --- 84,100 ---- def read(len, dest = '', ignore_eof = false) LOG "reading #{len} bytes..." read_bytes = 0 begin ! while read_bytes + @rbuf.bytesize < len ! dest << (s = rbuf_consume(@rbuf.bytesize)) ! read_bytes += s.bytesize rbuf_fill end dest << (s = rbuf_consume(len - read_bytes)) ! read_bytes += s.bytesize rescue EOFError raise unless ignore_eof end LOG "read #{read_bytes} bytes" dest *************** *** 103,114 **** def read_all(dest = '') LOG 'reading all...' read_bytes = 0 begin while true ! dest << (s = rbuf_consume(@rbuf.size)) ! read_bytes += s.size rbuf_fill end rescue EOFError ; end --- 103,114 ---- def read_all(dest = '') LOG 'reading all...' read_bytes = 0 begin while true ! dest << (s = rbuf_consume(@rbuf.bytesize)) ! read_bytes += s.bytesize rbuf_fill end rescue EOFError ; end *************** *** 119,132 **** def readuntil(terminator, ignore_eof = false) begin until idx = @rbuf.index(terminator) rbuf_fill end ! return rbuf_consume(idx + terminator.size) rescue EOFError raise unless ignore_eof ! return rbuf_consume(@rbuf.size) end end def readline readuntil("\n").chop --- 119,132 ---- def readuntil(terminator, ignore_eof = false) begin until idx = @rbuf.index(terminator) rbuf_fill end ! return rbuf_consume(idx + terminator.bytesize) rescue EOFError raise unless ignore_eof ! return rbuf_consume(@rbuf.bytesize) end end def readline readuntil("\n").chop *************** *** 236,246 **** def each_message_chunk LOG 'reading message...' LOG_off() read_bytes = 0 while (line = readuntil("\r\n")) != ".\r\n" ! read_bytes += line.size yield line.sub(/\A\./, '') end LOG_on() LOG "read message (#{read_bytes} bytes)" end --- 236,246 ---- def each_message_chunk LOG 'reading message...' LOG_off() read_bytes = 0 while (line = readuntil("\r\n")) != ".\r\n" ! read_bytes += line.bytesize yield line.sub(/\A\./, '') end LOG_on() LOG "read message (#{read_bytes} bytes)" end *************** *** 317,327 **** end def buffer_filling(buf, src) case src when String # for speeding up. ! 0.step(src.size - 1, 1024) do |i| buf << src[i, 1024] yield end when File # for speeding up. while s = src.read(1024) --- 317,327 ---- end def buffer_filling(buf, src) case src when String # for speeding up. ! 0.step(src.bytesize - 1, 1024) do |i| buf << src[i, 1024] yield end when File # for speeding up. while s = src.read(1024) *************** *** 329,339 **** yield end else # generic reader src.each do |str| buf << str ! yield if buf.size > 1024 end yield unless buf.empty? end end end --- 329,339 ---- yield end else # generic reader src.each do |str| buf << str ! yield if buf.bytesize > 1024 end yield unless buf.empty? end end end