提交 616ae95f 编写于 作者: P Patrick Walton

stdlib: Use an unsafe cast to speed up the memory writer

上级 180a3898
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册