-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Our resolver calculates which environment the variable is found in, but it’s still looked up by name in that map. A more efficient environment representation would store local variables in an array and look them up by index.
Extend the resolver to associate a unique index for each local variable declared in a scope. When resolving a variable access, look up both the scope the variable is in and its index and store that. In the interpreter, use that to quickly access a variable by its index instead of using a map.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
MatheusRich commentedon Apr 7, 2025
https://github.com/munificent/craftinginterpreters/tree/master/note/answers/chapter11_resolving/4/com/craftinginterpreters
MatheusRich commentedon Apr 9, 2025
This simple benchmark suggests I'll see 1.5-3x improvement with the change. It will be fun to compare with real results.