about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-21 01:21:51 -0700
committerbors <bors@rust-lang.org>2013-03-21 01:21:51 -0700
commit3ac89737ca60913c6777ef8a000e6aefb9f183c9 (patch)
treebf5b22e7001506bfa95b687761171054c6a126b8
parent9814d0d4128b07d4c40dc721c977f9216fd55e91 (diff)
parentf68f2282c10aa7bb8452906ecf98d13c716d5586 (diff)
downloadrust-3ac89737ca60913c6777ef8a000e6aefb9f183c9.tar.gz
rust-3ac89737ca60913c6777ef8a000e6aefb9f183c9.zip
auto merge of #5465 : sanxiyn/rust/remove-oldmap, r=sanxiyn
Improves resolve by 20% as measured by time-passes on rustc.
-rw-r--r--src/librustc/middle/resolve.rs74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs
index 6c2168548f1..2bba9a0df2e 100644
--- a/src/librustc/middle/resolve.rs
+++ b/src/librustc/middle/resolve.rs
@@ -77,6 +77,7 @@ use syntax::opt_vec::OptVec;
 
 use core::option::{Some, get, is_some, is_none};
 use core::str::{connect, split_str};
+use core::hashmap::linear::LinearMap;
 use std::oldmap::HashMap;
 
 // Definition mapping
@@ -456,7 +457,7 @@ pub struct Module {
     def_id: Option<def_id>,
     kind: ModuleKind,
 
-    children: @HashMap<ident,@mut NameBindings>,
+    children: @mut LinearMap<ident, @mut NameBindings>,
     imports: @mut ~[@ImportDirective],
 
     // The anonymous children of this node. Anonymous children are pseudo-
@@ -477,7 +478,7 @@ pub struct Module {
     anonymous_children: @HashMap<node_id,@mut Module>,
 
     // The status of resolving each import in this module.
-    import_resolutions: @HashMap<ident,@mut ImportResolution>,
+    import_resolutions: @mut LinearMap<ident, @mut ImportResolution>,
 
     // The number of unresolved globs that this module exports.
     glob_count: uint,
@@ -494,10 +495,10 @@ pub fn Module(parent_link: ParentLink,
         parent_link: parent_link,
         def_id: def_id,
         kind: kind,
-        children: @HashMap(),
+        children: @mut LinearMap::new(),
         imports: @mut ~[],
         anonymous_children: @HashMap(),
-        import_resolutions: @HashMap(),
+        import_resolutions: @mut LinearMap::new(),
         glob_count: 0,
         resolved_import_count: 0
     }
@@ -1024,7 +1025,7 @@ pub impl Resolver {
                                   *self.session.str_of(name)));
                     }
                 }
-                return (child, new_parent);
+                return (*child, new_parent);
             }
         }
     }
@@ -1614,7 +1615,7 @@ pub impl Resolver {
                         let name_bindings = parent_module.children.get(
                             &ident);
                         resolution.type_target =
-                            Some(Target(parent_module, name_bindings));
+                            Some(Target(parent_module, *name_bindings));
                       }
                     }
 
@@ -2168,13 +2169,13 @@ pub impl Resolver {
                 // Continue.
             }
             Some(child_name_bindings) => {
-                if (*child_name_bindings).defined_in_namespace(ValueNS) {
+                if child_name_bindings.defined_in_namespace(ValueNS) {
                     value_result = BoundResult(containing_module,
-                                               child_name_bindings);
+                                               *child_name_bindings);
                 }
-                if (*child_name_bindings).defined_in_namespace(TypeNS) {
+                if child_name_bindings.defined_in_namespace(TypeNS) {
                     type_result = BoundResult(containing_module,
-                                              child_name_bindings);
+                                              *child_name_bindings);
                 }
             }
         }
@@ -2244,11 +2245,11 @@ pub impl Resolver {
                         // The name is an import which has been fully
                         // resolved. We can, therefore, just follow it.
                         if value_result.is_unknown() {
-                            value_result = get_binding(import_resolution,
+                            value_result = get_binding(*import_resolution,
                                                        ValueNS);
                         }
                         if type_result.is_unknown() {
-                            type_result = get_binding(import_resolution,
+                            type_result = get_binding(*import_resolution,
                                                       TypeNS);
                         }
                     }
@@ -2355,9 +2356,9 @@ pub impl Resolver {
                 // Continue.
             }
             Some(child_name_bindings) => {
-                if (*child_name_bindings).defined_in_namespace(TypeNS) {
+                if child_name_bindings.defined_in_namespace(TypeNS) {
                     module_result = BoundResult(containing_module,
-                                                child_name_bindings);
+                                                *child_name_bindings);
                 }
             }
         }
@@ -2486,7 +2487,7 @@ pub impl Resolver {
 
         // Add all resolved imports from the containing module.
         for containing_module.import_resolutions.each
-                |&ident, &target_import_resolution| {
+                |&(ident, target_import_resolution)| {
 
             debug!("(resolving glob import) writing module resolution \
                     %? into `%s`",
@@ -2494,7 +2495,7 @@ pub impl Resolver {
                    self.module_to_str(module_));
 
             // Here we merge two import resolutions.
-            match module_.import_resolutions.find(&ident) {
+            match module_.import_resolutions.find(ident) {
                 None if target_import_resolution.privacy == Public => {
                     // Simple: just copy the old import resolution.
                     let new_import_resolution =
@@ -2507,7 +2508,7 @@ pub impl Resolver {
                         copy target_import_resolution.type_target;
 
                     module_.import_resolutions.insert
-                        (ident, new_import_resolution);
+                        (*ident, new_import_resolution);
                 }
                 None => { /* continue ... */ }
                 Some(dest_import_resolution) => {
@@ -2537,39 +2538,39 @@ pub impl Resolver {
         }
 
         // Add all children from the containing module.
-        for containing_module.children.each |&ident, &name_bindings| {
+        for containing_module.children.each |&(ident, name_bindings)| {
             let mut dest_import_resolution;
-            match module_.import_resolutions.find(&ident) {
+            match module_.import_resolutions.find(ident) {
                 None => {
                     // Create a new import resolution from this child.
                     dest_import_resolution = @mut ImportResolution(privacy,
                                                                    span,
                                                                    state);
                     module_.import_resolutions.insert
-                        (ident, dest_import_resolution);
+                        (*ident, dest_import_resolution);
                 }
                 Some(existing_import_resolution) => {
-                    dest_import_resolution = existing_import_resolution;
+                    dest_import_resolution = *existing_import_resolution;
                 }
             }
 
             debug!("(resolving glob import) writing resolution `%s` in `%s` \
                     to `%s`, privacy=%?",
-                   *self.session.str_of(ident),
+                   *self.session.str_of(*ident),
                    self.module_to_str(containing_module),
                    self.module_to_str(module_),
                    copy dest_import_resolution.privacy);
 
             // Merge the child item into the import resolution.
-            if (*name_bindings).defined_in_public_namespace(ValueNS) {
+            if name_bindings.defined_in_public_namespace(ValueNS) {
                 debug!("(resolving glob import) ... for value target");
                 dest_import_resolution.value_target =
-                    Some(Target(containing_module, name_bindings));
+                    Some(Target(containing_module, *name_bindings));
             }
-            if (*name_bindings).defined_in_public_namespace(TypeNS) {
+            if name_bindings.defined_in_public_namespace(TypeNS) {
                 debug!("(resolving glob import) ... for type target");
                 dest_import_resolution.type_target =
-                    Some(Target(containing_module, name_bindings));
+                    Some(Target(containing_module, *name_bindings));
             }
         }
 
@@ -2763,8 +2764,8 @@ pub impl Resolver {
 
         match module_.children.find(&name) {
             Some(name_bindings)
-                    if (*name_bindings).defined_in_namespace(namespace) => {
-                return Success(Target(module_, name_bindings));
+                    if name_bindings.defined_in_namespace(namespace) => {
+                return Success(Target(module_, *name_bindings));
             }
             Some(_) | None => { /* Not found; continue. */ }
         }
@@ -3008,10 +3009,9 @@ pub impl Resolver {
         // First, check the direct children of the module.
         match module_.children.find(&name) {
             Some(name_bindings)
-                    if (*name_bindings).defined_in_namespace(namespace) => {
-
+                    if name_bindings.defined_in_namespace(namespace) => {
                 debug!("(resolving name in module) found node as child");
-                return Success(Target(module_, name_bindings));
+                return Success(Target(module_, *name_bindings));
             }
             Some(_) | None => {
                 // Continue.
@@ -3193,7 +3193,7 @@ pub impl Resolver {
     fn add_exports_for_module(@mut self,
                               exports2: &mut ~[Export2],
                               module_: @mut Module) {
-        for module_.children.each |ident, namebindings| {
+        for module_.children.each |&(ident, namebindings)| {
             debug!("(computing exports) maybe export '%s'",
                    *self.session.str_of(*ident));
             self.add_exports_of_namebindings(&mut *exports2,
@@ -3208,7 +3208,7 @@ pub impl Resolver {
                                              false);
         }
 
-        for module_.import_resolutions.each |ident, importresolution| {
+        for module_.import_resolutions.each |&(ident, importresolution)| {
             if importresolution.privacy != Public {
                 debug!("(computing exports) not reexporting private `%s`",
                        *self.session.str_of(*ident));
@@ -5311,9 +5311,9 @@ pub impl Resolver {
         }
 
         debug!("Import resolutions:");
-        for module_.import_resolutions.each |&name, &import_resolution| {
+        for module_.import_resolutions.each |&(name, import_resolution)| {
             let mut value_repr;
-            match (*import_resolution).target_for_namespace(ValueNS) {
+            match import_resolution.target_for_namespace(ValueNS) {
                 None => { value_repr = ~""; }
                 Some(_) => {
                     value_repr = ~" value:?";
@@ -5322,7 +5322,7 @@ pub impl Resolver {
             }
 
             let mut type_repr;
-            match (*import_resolution).target_for_namespace(TypeNS) {
+            match import_resolution.target_for_namespace(TypeNS) {
                 None => { type_repr = ~""; }
                 Some(_) => {
                     type_repr = ~" type:?";
@@ -5330,7 +5330,7 @@ pub impl Resolver {
                 }
             }
 
-            debug!("* %s:%s%s", *self.session.str_of(name),
+            debug!("* %s:%s%s", *self.session.str_of(*name),
                    value_repr, type_repr);
         }
     }