mirror of
https://github.com/powdr-labs/powdr.git
synced 2026-04-20 03:03:25 -04:00
MutableState is the main way to get access to sub-machines during witness generation. We used to create copies of MutableState for each lookup, extracting the "current machine" where we need mutable access and creating copies of references to the other machines. This causes an allocation for each lookup (including fixed lookups, I think) which is bad for performance. This PR changes the approach to use RefCell instead: MutableState now owns the machines and for each call to a machine, we mutably borrow that machine. The RefCell mechanism ensures that there are no recursive calls to machines and also avoids allocations. I also changed the query callback to use non-mut references. The first and third commits only move code around.