@@ -77,6 +77,7 @@ use syntax::opt_vec::OptVec;
7777
7878use core:: option:: { Some , get, is_some, is_none} ;
7979use core:: str:: { connect, split_str} ;
80+ use core:: hashmap:: linear:: LinearMap ;
8081use std:: oldmap:: HashMap ;
8182
8283// Definition mapping
@@ -456,7 +457,7 @@ pub struct Module {
456457 def_id: Option<def_id>,
457458 kind: ModuleKind,
458459
459- children: @HashMap <ident,@mut NameBindings>,
460+ children: @mut LinearMap <ident, @mut NameBindings>,
460461 imports: @mut ~[@ImportDirective],
461462
462463 // The anonymous children of this node. Anonymous children are pseudo-
@@ -477,7 +478,7 @@ pub struct Module {
477478 anonymous_children: @HashMap<node_id,@mut Module>,
478479
479480 // The status of resolving each import in this module.
480- import_resolutions: @HashMap <ident,@mut ImportResolution>,
481+ import_resolutions: @mut LinearMap <ident, @mut ImportResolution>,
481482
482483 // The number of unresolved globs that this module exports.
483484 glob_count: uint,
@@ -494,10 +495,10 @@ pub fn Module(parent_link: ParentLink,
494495 parent_link: parent_link,
495496 def_id: def_id,
496497 kind: kind,
497- children: @HashMap (),
498+ children: @mut LinearMap::new (),
498499 imports: @mut ~[],
499500 anonymous_children: @HashMap(),
500- import_resolutions: @HashMap (),
501+ import_resolutions: @mut LinearMap::new (),
501502 glob_count: 0,
502503 resolved_import_count: 0
503504 }
@@ -1024,7 +1025,7 @@ pub impl Resolver {
10241025 *self.session.str_of(name)));
10251026 }
10261027 }
1027- return (child, new_parent);
1028+ return (* child, new_parent);
10281029 }
10291030 }
10301031 }
@@ -1614,7 +1615,7 @@ pub impl Resolver {
16141615 let name_bindings = parent_module.children.get(
16151616 &ident);
16161617 resolution.type_target =
1617- Some(Target(parent_module, name_bindings));
1618+ Some(Target(parent_module, * name_bindings));
16181619 }
16191620 }
16201621
@@ -2168,13 +2169,13 @@ pub impl Resolver {
21682169 // Continue.
21692170 }
21702171 Some ( child_name_bindings) => {
2171- if ( * child_name_bindings) . defined_in_namespace ( ValueNS ) {
2172+ if child_name_bindings. defined_in_namespace ( ValueNS ) {
21722173 value_result = BoundResult ( containing_module,
2173- child_name_bindings) ;
2174+ * child_name_bindings) ;
21742175 }
2175- if ( * child_name_bindings) . defined_in_namespace ( TypeNS ) {
2176+ if child_name_bindings. defined_in_namespace ( TypeNS ) {
21762177 type_result = BoundResult ( containing_module,
2177- child_name_bindings) ;
2178+ * child_name_bindings) ;
21782179 }
21792180 }
21802181 }
@@ -2244,11 +2245,11 @@ pub impl Resolver {
22442245 // The name is an import which has been fully
22452246 // resolved. We can, therefore, just follow it.
22462247 if value_result. is_unknown ( ) {
2247- value_result = get_binding ( import_resolution,
2248+ value_result = get_binding ( * import_resolution,
22482249 ValueNS ) ;
22492250 }
22502251 if type_result. is_unknown ( ) {
2251- type_result = get_binding ( import_resolution,
2252+ type_result = get_binding ( * import_resolution,
22522253 TypeNS ) ;
22532254 }
22542255 }
@@ -2355,9 +2356,9 @@ pub impl Resolver {
23552356 // Continue.
23562357 }
23572358 Some ( child_name_bindings) => {
2358- if ( * child_name_bindings) . defined_in_namespace ( TypeNS ) {
2359+ if child_name_bindings. defined_in_namespace ( TypeNS ) {
23592360 module_result = BoundResult ( containing_module,
2360- child_name_bindings) ;
2361+ * child_name_bindings) ;
23612362 }
23622363 }
23632364 }
@@ -2486,15 +2487,15 @@ pub impl Resolver {
24862487
24872488 // Add all resolved imports from the containing module.
24882489 for containing_module.import_resolutions.each
2489- |&ident, & target_import_resolution| {
2490+ |&( ident, target_import_resolution) | {
24902491
24912492 debug!(" ( resolving glob import) writing module resolution \
24922493 %? into `%s`",
24932494 is_none( & mut target_import_resolution. type_target) ,
24942495 self . module_to_str( module_) ) ;
24952496
24962497 // Here we merge two import resolutions.
2497- match module_. import_resolutions . find ( & ident) {
2498+ match module_. import_resolutions . find ( ident) {
24982499 None if target_import_resolution. privacy == Public => {
24992500 // Simple: just copy the old import resolution.
25002501 let new_import_resolution =
@@ -2507,7 +2508,7 @@ pub impl Resolver {
25072508 copy target_import_resolution. type_target ;
25082509
25092510 module_. import_resolutions . insert
2510- ( ident, new_import_resolution) ;
2511+ ( * ident, new_import_resolution) ;
25112512 }
25122513 None => { /* continue ... */ }
25132514 Some ( dest_import_resolution) => {
@@ -2537,39 +2538,39 @@ pub impl Resolver {
25372538 }
25382539
25392540 // Add all children from the containing module.
2540- for containing_module. children. each |& ident, & name_bindings| {
2541+ for containing_module. children. each |& ( ident, name_bindings) | {
25412542 let mut dest_import_resolution;
2542- match module_. import_resolutions. find( & ident) {
2543+ match module_. import_resolutions. find( ident) {
25432544 None => {
25442545 // Create a new import resolution from this child.
25452546 dest_import_resolution = @mut ImportResolution ( privacy,
25462547 span,
25472548 state) ;
25482549 module_. import_resolutions . insert
2549- ( ident, dest_import_resolution) ;
2550+ ( * ident, dest_import_resolution) ;
25502551 }
25512552 Some ( existing_import_resolution) => {
2552- dest_import_resolution = existing_import_resolution;
2553+ dest_import_resolution = * existing_import_resolution;
25532554 }
25542555 }
25552556
25562557 debug ! ( "(resolving glob import) writing resolution `%s` in `%s` \
25572558 to `%s`, privacy=%?",
2558- * self . session. str_of( ident) ,
2559+ * self . session. str_of( * ident) ,
25592560 self . module_to_str( containing_module) ,
25602561 self . module_to_str( module_) ,
25612562 copy dest_import_resolution. privacy) ;
25622563
25632564 // Merge the child item into the import resolution.
2564- if ( * name_bindings) . defined_in_public_namespace ( ValueNS ) {
2565+ if name_bindings. defined_in_public_namespace ( ValueNS ) {
25652566 debug ! ( "(resolving glob import) ... for value target" ) ;
25662567 dest_import_resolution. value_target =
2567- Some ( Target ( containing_module, name_bindings) ) ;
2568+ Some ( Target ( containing_module, * name_bindings) ) ;
25682569 }
2569- if ( * name_bindings) . defined_in_public_namespace ( TypeNS ) {
2570+ if name_bindings. defined_in_public_namespace ( TypeNS ) {
25702571 debug ! ( "(resolving glob import) ... for type target" ) ;
25712572 dest_import_resolution. type_target =
2572- Some ( Target ( containing_module, name_bindings) ) ;
2573+ Some ( Target ( containing_module, * name_bindings) ) ;
25732574 }
25742575 }
25752576
@@ -2763,8 +2764,8 @@ pub impl Resolver {
27632764
27642765 match module_. children . find ( & name) {
27652766 Some ( name_bindings)
2766- if ( * name_bindings) . defined_in_namespace ( namespace) => {
2767- return Success ( Target ( module_, name_bindings) ) ;
2767+ if name_bindings. defined_in_namespace ( namespace) => {
2768+ return Success ( Target ( module_, * name_bindings) ) ;
27682769 }
27692770 Some ( _) | None => { /* Not found; continue. */ }
27702771 }
@@ -3008,10 +3009,9 @@ pub impl Resolver {
30083009 // First, check the direct children of the module.
30093010 match module_. children . find ( & name) {
30103011 Some ( name_bindings)
3011- if ( * name_bindings) . defined_in_namespace ( namespace) => {
3012-
3012+ if name_bindings. defined_in_namespace ( namespace) => {
30133013 debug ! ( "(resolving name in module) found node as child" ) ;
3014- return Success ( Target ( module_, name_bindings) ) ;
3014+ return Success ( Target ( module_, * name_bindings) ) ;
30153015 }
30163016 Some ( _) | None => {
30173017 // Continue.
@@ -3193,7 +3193,7 @@ pub impl Resolver {
31933193 fn add_exports_for_module(@mut self,
31943194 exports2: &mut ~[Export2],
31953195 module_: @mut Module) {
3196- for module_.children.each |ident, namebindings| {
3196+ for module_.children.each |&( ident, namebindings) | {
31973197 debug!(" ( computing exports) maybe export ' %s' ",
31983198 *self.session.str_of(*ident));
31993199 self.add_exports_of_namebindings(&mut *exports2,
@@ -3208,7 +3208,7 @@ pub impl Resolver {
32083208 false);
32093209 }
32103210
3211- for module_.import_resolutions.each |ident, importresolution| {
3211+ for module_.import_resolutions.each |&( ident, importresolution) | {
32123212 if importresolution.privacy != Public {
32133213 debug!(" ( computing exports) not reexporting private `%s`",
32143214 * self . session. str_of( * ident) ) ;
@@ -5311,9 +5311,9 @@ pub impl Resolver {
53115311 }
53125312
53135313 debug ! ( "Import resolutions:" ) ;
5314- for module_. import_resolutions. each |& name, & import_resolution| {
5314+ for module_. import_resolutions. each |& ( name, import_resolution) | {
53155315 let mut value_repr;
5316- match ( * import_resolution) . target_for_namespace( ValueNS ) {
5316+ match import_resolution. target_for_namespace( ValueNS ) {
53175317 None => { value_repr = ~""; }
53185318 Some ( _) => {
53195319 value_repr = ~" value: ?";
@@ -5322,15 +5322,15 @@ pub impl Resolver {
53225322 }
53235323
53245324 let mut type_repr;
5325- match ( * import_resolution) . target_for_namespace( TypeNS ) {
5325+ match import_resolution. target_for_namespace( TypeNS ) {
53265326 None => { type_repr = ~""; }
53275327 Some ( _) => {
53285328 type_repr = ~" type : ?";
53295329 // FIXME #4954
53305330 }
53315331 }
53325332
5333- debug!( "* %s: %s%s", * self . session. str_of( name) ,
5333+ debug ! ( "* %s:%s%s" , * self . session. str_of( * name) ,
53345334 value_repr, type_repr) ;
53355335 }
53365336 }
0 commit comments