Skip to content

Remove a hacky buffer extraction from metadata #11295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::hashmap::{HashMap, HashSet};
use std::io::mem::MemWriter;
use std::io::{Writer, Seek, Decorator};
use std::str;
use std::util;
use std::vec;

use extra::serialize::Encodable;
Expand Down Expand Up @@ -1797,6 +1796,11 @@ pub static metadata_encoding_version : &'static [u8] =

pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
let mut wr = MemWriter::new();
encode_metadata_inner(&mut wr, parms, crate);
wr.inner()
}

fn encode_metadata_inner(wr: &mut MemWriter, parms: EncodeParams, crate: &Crate) {
let stats = Stats {
inline_bytes: Cell::new(0),
attr_bytes: Cell::new(0),
Expand Down Expand Up @@ -1838,7 +1842,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
reachable: reachable,
};

let mut ebml_w = writer::Encoder(&mut wr);
let mut ebml_w = writer::Encoder(wr);

encode_hash(&mut ebml_w, ecx.link_meta.crate_hash);

Expand Down Expand Up @@ -1909,10 +1913,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
// Pad this, since something (LLVM, presumably) is cutting off the
// remaining % 4 bytes.
ebml_w.writer.write(&[0u8, 0u8, 0u8, 0u8]);

// This is a horrible thing to do to the outer MemWriter, but thankfully we
// don't use it again so... it's ok right?
return util::replace(ebml_w.writer.inner_mut_ref(), ~[]);
}

// Get the encoded string for a type
Expand Down