提交 5cd9d4d9 编写于 作者: P Patrick Walton

libcore: Make BytesWriters not require shared boxes.

上级 d6e731d8
......@@ -687,7 +687,7 @@ struct BytesWriter {
mut pos: uint,
}
impl @BytesWriter: Writer {
impl BytesWriter: Writer {
fn write(v: &[const u8]) {
do self.buf.swap |buf| {
let mut buf <- buf;
......@@ -716,12 +716,20 @@ fn flush() -> int { 0 }
fn get_type() -> WriterType { File }
}
fn BytesWriter() -> @BytesWriter {
@BytesWriter { buf: DVec(), mut pos: 0u }
impl @BytesWriter : Writer {
fn write(v: &[const u8]) { (*self).write(v) }
fn seek(offset: int, whence: SeekStyle) { (*self).seek(offset, whence) }
fn tell() -> uint { (*self).tell() }
fn flush() -> int { (*self).flush() }
fn get_type() -> WriterType { (*self).get_type() }
}
fn BytesWriter() -> BytesWriter {
BytesWriter { buf: DVec(), mut pos: 0u }
}
fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
let wr = BytesWriter();
let wr = @BytesWriter();
f(wr as Writer);
wr.buf.check_out(|buf| buf)
}
......
......@@ -1093,7 +1093,7 @@ fn encode_hash(ebml_w: ebml::Writer, hash: ~str) {
0, 0, 0, 1 ];
fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
let wr = io::BytesWriter();
let wr = @io::BytesWriter();
let stats =
{mut inline_bytes: 0,
mut attr_bytes: 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册