Currently CtxModuleDef stores before and after as Array[(VarName, Term)]. Every go_right/go_left step copies the entire array — O(N) per step, O(N²) over a full traversal.
Fix: Replace with reversed/forward @list.List (functional cons-list). Navigation becomes O(1) cons/decons. plug iterates once to reconstruct the array.
When: Profile first. Lambda modules are typically small, so this may not matter in practice.
Files: lang/lambda/zipper/zipper.mbt — TermCtx::CtxModuleDef, go_down, go_right, go_left, plug
Currently
CtxModuleDefstoresbeforeandafterasArray[(VarName, Term)]. Everygo_right/go_leftstep copies the entire array — O(N) per step, O(N²) over a full traversal.Fix: Replace with reversed/forward
@list.List(functional cons-list). Navigation becomes O(1) cons/decons.plugiterates once to reconstruct the array.When: Profile first. Lambda modules are typically small, so this may not matter in practice.
Files:
lang/lambda/zipper/zipper.mbt—TermCtx::CtxModuleDef,go_down,go_right,go_left,plug