From 3a570075b191832e8ed63e018db871017132701a Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 7 Jan 2013 12:48:46 -0800 Subject: [PATCH] librustc: Remove unused `mod_path_map`. This was expensive to build. Saves another 15% or so. r=tjc --- src/librustc/metadata/cstore.rs | 25 ++----------------------- src/librustc/metadata/decoder.rs | 29 ----------------------------- 2 files changed, 2 insertions(+), 52 deletions(-) diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 212f9558331..5d4694df7d3 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -43,7 +43,6 @@ export get_used_link_args; export add_use_stmt_cnum; export find_use_stmt_cnum; export get_dep_hashes; -export get_path; // A map from external crate numbers (as decoded from some crate file) to @@ -52,11 +51,6 @@ export get_path; // own crate numbers. type cnum_map = map::HashMap; -// Multiple items may have the same def_id in crate metadata. They may be -// renamed imports or reexports. This map keeps the "real" module path -// and def_id. -type mod_path_map = map::HashMap; - type crate_metadata = @{name: ~str, data: @~[u8], cnum_map: cnum_map, @@ -72,7 +66,6 @@ enum CStore { private(cstore_private), } type cstore_private = @{metas: map::HashMap, use_crate_map: use_crate_map, - mod_path_map: mod_path_map, mut used_crate_files: ~[Path], mut used_libraries: ~[~str], mut used_link_args: ~[~str], @@ -89,10 +82,8 @@ pure fn p(cstore: CStore) -> cstore_private { fn mk_cstore(intr: @ident_interner) -> CStore { let meta_cache = map::HashMap(); let crate_map = map::HashMap(); - let mod_path_map = HashMap(); return private(@{metas: meta_cache, use_crate_map: crate_map, - mod_path_map: mod_path_map, mut used_crate_files: ~[], mut used_libraries: ~[], mut used_link_args: ~[], @@ -113,18 +104,10 @@ fn get_crate_vers(cstore: CStore, cnum: ast::crate_num) -> ~str { return decoder::get_crate_vers(cdata.data); } -fn set_crate_data(cstore: CStore, cnum: ast::crate_num, +fn set_crate_data(cstore: CStore, + cnum: ast::crate_num, data: crate_metadata) { p(cstore).metas.insert(cnum, data); - let get_crate_data: decoder::GetCrateDataCb = |cnum| { - cstore::get_crate_data(cstore, cnum) - }; - for vec::each(decoder::get_crate_module_paths(cstore.intr, data, - get_crate_data)) |dp| { - let (did, path) = *dp; - let d = {crate: cnum, node: did.node}; - p(cstore).mod_path_map.insert(d, @path); - } } fn have_crate_data(cstore: CStore, cnum: ast::crate_num) -> bool { @@ -197,10 +180,6 @@ fn get_dep_hashes(cstore: CStore) -> ~[~str] { return vec::map(sorted, mapper); } -fn get_path(cstore: CStore, d: ast::def_id) -> ~[~str] { - option::map_default(&p(cstore).mod_path_map.find(d), ~[], - |ds| str::split_str(**ds, ~"::")) -} // Local Variables: // mode: rust // fill-column: 78; diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index d9486bf4e9f..91926ff2f9a 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -68,7 +68,6 @@ export get_supertraits; export get_method_names_if_trait; export get_type_name_if_impl; export get_item_attrs; -export get_crate_module_paths; export def_like; export dl_def; export dl_impl; @@ -1121,34 +1120,6 @@ fn iter_crate_items(intr: @ident_interner, cdata: cmd, } } -fn get_crate_module_paths(intr: @ident_interner, cdata: cmd, - get_crate_data: GetCrateDataCb) - -> ~[(ast::def_id, ~str)] { - fn mod_of_path(p: ~str) -> ~str { - str::connect(vec::init(str::split_str(p, ~"::")), ~"::") - } - - // find all module (path, def_ids), which are not - // fowarded path due to renamed import or reexport - let mut res = ~[]; - let mods = map::HashMap(); - do iter_crate_items(intr, cdata, get_crate_data) |path, did| { - let m = mod_of_path(path); - if str::is_not_empty(m) { - // if m has a sub-item, it must be a module - mods.insert(m, true); - } - // Collect everything by now. There might be multiple - // paths pointing to the same did. Those will be - // unified later by using the mods map - res.push((did, path)); - } - return do vec::filter(res) |x| { - let (_, xp) = *x; - mods.contains_key(xp) - } -} - fn list_crate_metadata(intr: @ident_interner, bytes: @~[u8], out: io::Writer) { let hash = get_crate_hash(bytes);