Skip to content

Commit

Permalink
rustc: middle: use cheaper Name in resolve::Export instead of String.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Dec 20, 2014
1 parent f027607 commit 10a862d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -451,8 +451,6 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
mod_path: PathElems,
exp: &middle::resolve::Export) {
if let Some(ast_map::NodeItem(item)) = ecx.tcx.map.find(exp.def_id.node) {
let original_name = token::get_ident(item.ident);

let path_differs = ecx.tcx.map.with_path(exp.def_id.node, |path| {
let (mut a, mut b) = (path, mod_path.clone());
loop {
Expand All @@ -474,16 +472,16 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
// encoded metadata for static methods relative to Bar,
// but not yet for Foo.
//
if path_differs || original_name.get() != exp.name {
if path_differs || item.ident.name != exp.name {
if !encode_reexported_static_base_methods(ecx, rbml_w, exp) {
if encode_reexported_static_trait_methods(ecx, rbml_w, exp) {
debug!("(encode reexported static methods) {} [trait]",
original_name);
item.ident.name);
}
}
else {
debug!("(encode reexported static methods) {} [base]",
original_name);
item.ident.name);
}
}
}
Expand Down Expand Up @@ -534,7 +532,7 @@ fn encode_reexports(ecx: &EncodeContext,
rbml_w.wr_str(def_to_string(exp.def_id).as_slice());
rbml_w.end_tag();
rbml_w.start_tag(tag_items_data_item_reexport_name);
rbml_w.wr_str(exp.name.as_slice());
rbml_w.wr_str(exp.name.as_str());
rbml_w.end_tag();
rbml_w.end_tag();
encode_reexported_static_methods(ecx, rbml_w, path.clone(), exp);
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/resolve.rs
Expand Up @@ -98,7 +98,7 @@ type BindingMap = HashMap<Name, BindingInfo>;
pub type ExportMap = NodeMap<Vec<Export>>;

pub struct Export {
pub name: String, // The name of the target.
pub name: Name, // The name of the target.
pub def_id: DefId, // The definition of the target.
}

Expand Down Expand Up @@ -3873,11 +3873,10 @@ impl<'a> Resolver<'a> {
ns: Namespace) {
match namebindings.def_for_namespace(ns) {
Some(d) => {
let name = token::get_name(name);
debug!("(computing exports) YES: export '{}' => {}",
name, d.def_id());
exports.push(Export {
name: name.get().to_string(),
name: name,
def_id: d.def_id()
});
}
Expand Down

0 comments on commit 10a862d

Please sign in to comment.