halve the number of lookups into References

This commit is contained in:
Folkert 2022-04-20 20:22:52 +02:00
parent b557929276
commit 9d17a075d9
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 5 additions and 9 deletions

View file

@ -1594,8 +1594,7 @@ pub fn can_defs_with_return<'a>(
// Now that we've collected all the references, check to see if any of the new idents // Now that we've collected all the references, check to see if any of the new idents
// we defined went unused by the return expression. If any were unused, report it. // we defined went unused by the return expression. If any were unused, report it.
for (symbol, region) in symbols_introduced { for (symbol, region) in symbols_introduced {
if !output.references.has_value_lookup(symbol) if !output.references.has_type_or_value_lookup(symbol)
&& !output.references.has_type_lookup(symbol)
&& !scope.abilities_store.is_specialization_name(symbol) && !scope.abilities_store.is_specialization_name(symbol)
{ {
env.problem(Problem::UnusedDef(symbol, region)); env.problem(Problem::UnusedDef(symbol, region));

View file

@ -1072,10 +1072,8 @@ fn canonicalize_when_branch<'a>(
for (symbol, region) in scope.symbols() { for (symbol, region) in scope.symbols() {
let symbol = *symbol; let symbol = *symbol;
if !output.references.has_value_lookup(symbol) if !output.references.has_type_or_value_lookup(symbol)
&& !output.references.has_type_lookup(symbol) && !branch_output.references.has_type_or_value_lookup(symbol)
&& !branch_output.references.has_value_lookup(symbol)
&& !branch_output.references.has_type_lookup(symbol)
&& !original_scope.contains_symbol(symbol) && !original_scope.contains_symbol(symbol)
&& !scope.abilities_store.is_specialization_name(symbol) && !scope.abilities_store.is_specialization_name(symbol)
{ {

View file

@ -302,8 +302,7 @@ pub fn canonicalize_module_defs<'a>(
// See if any of the new idents we defined went unused. // See if any of the new idents we defined went unused.
// If any were unused and also not exposed, report it. // If any were unused and also not exposed, report it.
for (symbol, region) in symbols_introduced { for (symbol, region) in symbols_introduced {
if !output.references.has_value_lookup(symbol) if !output.references.has_type_or_value_lookup(symbol)
&& !output.references.has_type_lookup(symbol)
&& !exposed_symbols.contains(&symbol) && !exposed_symbols.contains(&symbol)
&& !scope.abilities_store.is_specialization_name(symbol) && !scope.abilities_store.is_specialization_name(symbol)
{ {

View file

@ -153,7 +153,7 @@ impl References {
false false
} }
pub fn has_type_lookup(&self, symbol: Symbol) -> bool { fn has_type_lookup(&self, symbol: Symbol) -> bool {
let it = self.symbols.iter().zip(self.bitflags.iter()); let it = self.symbols.iter().zip(self.bitflags.iter());
for (a, b) in it { for (a, b) in it {