Simplify lookup_local_symbol

This simplifies lookup_local_symbol a little, by having it check
whether the current block is the static or global block, instead of
first searching for the static block.
This commit is contained in:
Tom Tromey
2024-05-23 09:35:46 -06:00
parent 5ae8852d26
commit 67554fb777

View File

@@ -2222,17 +2222,12 @@ lookup_local_symbol (const char *name,
if (block == nullptr)
return {};
struct symbol *sym;
const struct block *static_block = block->static_block ();
const char *scope = block->scope ();
/* Check if it's a global block. */
if (static_block == nullptr)
return {};
while (block != static_block)
while (!block->is_global_block () && !block->is_static_block ())
{
sym = lookup_symbol_in_block (name, match_type, block, domain);
struct symbol *sym = lookup_symbol_in_block (name, match_type,
block, domain);
if (sym != NULL)
return (struct block_symbol) {sym, block};