about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
authorMichael Neumann <mneumann@ntecs.de>2013-01-25 05:17:25 -0600
committerBrian Anderson <banderson@mozilla.com>2013-01-28 14:40:11 -0800
commit1ecdf3abc1cf08e76dbe309e1ee9255f899427f7 (patch)
tree9dab5ed5744680b7764cf65181a5ad2f511d5130 /src/rt/rust_kernel.cpp
parent0c3ef3cc6bddaa4bcdb25f5562286a71b59cc15d (diff)
downloadrust-1ecdf3abc1cf08e76dbe309e1ee9255f899427f7.tar.gz
rust-1ecdf3abc1cf08e76dbe309e1ee9255f899427f7.zip
Greatly improve performance for TcpSocketBuf.read
For every call to the read() function the internal buffer was copied
into a new buffer (minus the bytes copied into the result buffer). When
the internal buffer is large enough, this severely affects performance,
especially when read_line() is used which calls read_byte() (which calls
read()) for each read byte.

For line oriented I/O this wasn't all that bad, because the internal
buffers usually never were very big. The effect is much more visible
once the buffer grows larger.

Now we always first look into the internal buffer and copy as many bytes
as possible (and desired) into the result buffer. If we need more, we
call the socket read function and use the result as the new internal
buffer, then continue to copy from the (new) internal buffer, and so on.
Diffstat (limited to 'src/rt/rust_kernel.cpp')
0 files changed, 0 insertions, 0 deletions