search imports first; they are likely to be small, andl likely to contain used types

This commit is contained in:
Folkert 2022-04-30 19:58:09 +02:00
parent c3ef37d1bd
commit 15f860e6d7
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -171,17 +171,10 @@ impl Scope {
/// Is an identifier in scope, either in the locals or imports /// Is an identifier in scope, either in the locals or imports
fn scope_contains_ident(&self, ident: &Ident) -> ContainsIdent { fn scope_contains_ident(&self, ident: &Ident) -> ContainsIdent {
let result = self.locals.contains_ident(ident); // exposed imports are likely to be small
match result { match self.has_imported(ident) {
ContainsIdent::InScope(_, _) => result,
ContainsIdent::NotInScope(_) => match self.has_imported(ident) {
Some((symbol, region)) => ContainsIdent::InScope(symbol, region), Some((symbol, region)) => ContainsIdent::InScope(symbol, region),
None => result, None => self.locals.contains_ident(ident),
},
ContainsIdent::NotPresent => match self.has_imported(ident) {
Some((symbol, region)) => ContainsIdent::InScope(symbol, region),
None => ContainsIdent::NotPresent,
},
} }
} }