diff --git a/src/lib/io.rs b/src/lib/io.rs index 2c2c0dbf5391c46a4f49ed168c7b8eca093125cf..4c1bf2dfb2b120e15009398b2cd34220e198fc8c 100644 --- a/src/lib/io.rs +++ b/src/lib/io.rs @@ -450,7 +450,17 @@ fn stdout() -> writer { state obj byte_buf_writer(mutable_byte_buf buf) { fn write(vec[u8] v) { - // FIXME: optimize + // Fast path. + if (buf.pos == _vec.len[mutable u8](buf.buf)) { + // FIXME: Fix our type system. There's no reason you shouldn't be + // able to add a mutable vector to an immutable one. + auto mv = _vec.rustrt.unsafe_vec_to_mut[u8](v); + buf.buf += mv; + buf.pos += _vec.len[u8](v); + ret; + } + + // FIXME: Optimize. These should be unique pointers. auto vlen = _vec.len[u8](v); auto vpos = 0u; while (vpos < vlen) {