Skip to content

Commit e84323e

Browse files
committed
Switch Module.children from oldmap
1 parent a14ec73 commit e84323e

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/librustc/middle/resolve.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ use syntax::opt_vec::OptVec;
7777

7878
use core::option::{Some, get, is_some, is_none};
7979
use core::str::{connect, split_str};
80+
use core::hashmap::linear::LinearMap;
8081
use 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-
@@ -494,7 +495,7 @@ 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(),
500501
import_resolutions: @HashMap(),
@@ -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
@@ -2165,13 +2166,13 @@ pub impl Resolver {
21652166
// Continue.
21662167
}
21672168
Some(child_name_bindings) => {
2168-
if (*child_name_bindings).defined_in_namespace(ValueNS) {
2169+
if child_name_bindings.defined_in_namespace(ValueNS) {
21692170
value_result = BoundResult(containing_module,
2170-
child_name_bindings);
2171+
*child_name_bindings);
21712172
}
2172-
if (*child_name_bindings).defined_in_namespace(TypeNS) {
2173+
if child_name_bindings.defined_in_namespace(TypeNS) {
21732174
type_result = BoundResult(containing_module,
2174-
child_name_bindings);
2175+
*child_name_bindings);
21752176
}
21762177
}
21772178
}
@@ -2352,9 +2353,9 @@ pub impl Resolver {
23522353
// Continue.
23532354
}
23542355
Some(child_name_bindings) => {
2355-
if (*child_name_bindings).defined_in_namespace(TypeNS) {
2356+
if child_name_bindings.defined_in_namespace(TypeNS) {
23562357
module_result = BoundResult(containing_module,
2357-
child_name_bindings);
2358+
*child_name_bindings);
23582359
}
23592360
}
23602361
}
@@ -2534,16 +2535,16 @@ pub impl Resolver {
25342535
}
25352536

25362537
// Add all children from the containing module.
2537-
for containing_module.children.each |&ident, &name_bindings| {
2538+
for containing_module.children.each |&(ident, name_bindings)| {
25382539
let mut dest_import_resolution;
2539-
match module_.import_resolutions.find(&ident) {
2540+
match module_.import_resolutions.find(ident) {
25402541
None => {
25412542
// Create a new import resolution from this child.
25422543
dest_import_resolution = @mut ImportResolution(privacy,
25432544
span,
25442545
state);
25452546
module_.import_resolutions.insert
2546-
(ident, dest_import_resolution);
2547+
(*ident, dest_import_resolution);
25472548
}
25482549
Some(existing_import_resolution) => {
25492550
dest_import_resolution = existing_import_resolution;
@@ -2552,21 +2553,21 @@ pub impl Resolver {
25522553

25532554
debug!("(resolving glob import) writing resolution `%s` in `%s` \
25542555
to `%s`, privacy=%?",
2555-
*self.session.str_of(ident),
2556+
*self.session.str_of(*ident),
25562557
self.module_to_str(containing_module),
25572558
self.module_to_str(module_),
25582559
copy dest_import_resolution.privacy);
25592560

25602561
// Merge the child item into the import resolution.
2561-
if (*name_bindings).defined_in_public_namespace(ValueNS) {
2562+
if name_bindings.defined_in_public_namespace(ValueNS) {
25622563
debug!("(resolving glob import) ... for value target");
25632564
dest_import_resolution.value_target =
2564-
Some(Target(containing_module, name_bindings));
2565+
Some(Target(containing_module, *name_bindings));
25652566
}
2566-
if (*name_bindings).defined_in_public_namespace(TypeNS) {
2567+
if name_bindings.defined_in_public_namespace(TypeNS) {
25672568
debug!("(resolving glob import) ... for type target");
25682569
dest_import_resolution.type_target =
2569-
Some(Target(containing_module, name_bindings));
2570+
Some(Target(containing_module, *name_bindings));
25702571
}
25712572
}
25722573

@@ -2760,8 +2761,8 @@ pub impl Resolver {
27602761

27612762
match module_.children.find(&name) {
27622763
Some(name_bindings)
2763-
if (*name_bindings).defined_in_namespace(namespace) => {
2764-
return Success(Target(module_, name_bindings));
2764+
if name_bindings.defined_in_namespace(namespace) => {
2765+
return Success(Target(module_, *name_bindings));
27652766
}
27662767
Some(_) | None => { /* Not found; continue. */ }
27672768
}
@@ -3005,10 +3006,9 @@ pub impl Resolver {
30053006
// First, check the direct children of the module.
30063007
match module_.children.find(&name) {
30073008
Some(name_bindings)
3008-
if (*name_bindings).defined_in_namespace(namespace) => {
3009-
3009+
if name_bindings.defined_in_namespace(namespace) => {
30103010
debug!("(resolving name in module) found node as child");
3011-
return Success(Target(module_, name_bindings));
3011+
return Success(Target(module_, *name_bindings));
30123012
}
30133013
Some(_) | None => {
30143014
// Continue.
@@ -3190,7 +3190,7 @@ pub impl Resolver {
31903190
fn add_exports_for_module(@mut self,
31913191
exports2: &mut ~[Export2],
31923192
module_: @mut Module) {
3193-
for module_.children.each |ident, namebindings| {
3193+
for module_.children.each |&(ident, namebindings)| {
31943194
debug!("(computing exports) maybe export '%s'",
31953195
*self.session.str_of(*ident));
31963196
self.add_exports_of_namebindings(&mut *exports2,

0 commit comments

Comments
 (0)