libcore: Make BytesWriters not require shared boxes.

This commit is contained in:
Patrick Walton 2012-09-20 11:17:15 -07:00
parent d6e731d823
commit 5cd9d4d9dd
2 changed files with 13 additions and 5 deletions

View File

@ -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 @@ impl @BytesWriter: Writer {
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)
}

View File

@ -1093,7 +1093,7 @@ const metadata_encoding_version : &[u8] = &[0x72, //'r' as u8,
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,