mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Build VarStorage insts more efficiently. (#7422)
Instead of traversing the entire pattern block looking for `VarPattern`s, we keep track of them on creation, and then build `VarStorage`s directly from that list. This also gets rid of the global `var_storage_map`, and instead keep that information narrowly scoped to each full-pattern, and consume it in a single linear traversal instead of with random-access lookups. To enable that, this fixes a parse bug where nested `var` patterns were getting diagnosed but not marked as errors.
This commit is contained in:
@@ -674,9 +674,8 @@ auto MatchContext::DoVarPreWorkImpl(State state,
|
||||
|
||||
// In a `var`/`let` declaration, the `VarStorage` inst is created before
|
||||
// we start pattern matching.
|
||||
auto lookup_result = context_.var_storage_map().Lookup(entry.pattern_id);
|
||||
CARBON_CHECK(lookup_result);
|
||||
auto storage_id = lookup_result.value();
|
||||
auto storage_id =
|
||||
context_.full_pattern_stack().GetLocalVarStorage(entry.pattern_id);
|
||||
if (scrutinee_id.has_value()) {
|
||||
auto init_id =
|
||||
InitializeExisting(context_, SemIR::LocId(entry.pattern_id),
|
||||
|
||||
Reference in New Issue
Block a user