Skip to content

Commit 5cd9d4d

Browse files
committed
libcore: Make BytesWriters not require shared boxes.
1 parent d6e731d commit 5cd9d4d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/libcore/io.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ struct BytesWriter {
687687
mut pos: uint,
688688
}
689689
690-
impl @BytesWriter: Writer {
690+
impl BytesWriter: Writer {
691691
fn write(v: &[const u8]) {
692692
do self.buf.swap |buf| {
693693
let mut buf <- buf;
@@ -716,12 +716,20 @@ impl @BytesWriter: Writer {
716716
fn get_type() -> WriterType { File }
717717
}
718718
719-
fn BytesWriter() -> @BytesWriter {
720-
@BytesWriter { buf: DVec(), mut pos: 0u }
719+
impl @BytesWriter : Writer {
720+
fn write(v: &[const u8]) { (*self).write(v) }
721+
fn seek(offset: int, whence: SeekStyle) { (*self).seek(offset, whence) }
722+
fn tell() -> uint { (*self).tell() }
723+
fn flush() -> int { (*self).flush() }
724+
fn get_type() -> WriterType { (*self).get_type() }
725+
}
726+
727+
fn BytesWriter() -> BytesWriter {
728+
BytesWriter { buf: DVec(), mut pos: 0u }
721729
}
722730
723731
fn with_bytes_writer(f: fn(Writer)) -> ~[u8] {
724-
let wr = BytesWriter();
732+
let wr = @BytesWriter();
725733
f(wr as Writer);
726734
wr.buf.check_out(|buf| buf)
727735
}

src/rustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ const metadata_encoding_version : &[u8] = &[0x72, //'r' as u8,
10931093
0, 0, 0, 1 ];
10941094

10951095
fn encode_metadata(parms: encode_parms, crate: @crate) -> ~[u8] {
1096-
let wr = io::BytesWriter();
1096+
let wr = @io::BytesWriter();
10971097
let stats =
10981098
{mut inline_bytes: 0,
10991099
mut attr_bytes: 0,

0 commit comments

Comments
 (0)