Skip to content

Commit 98eafa5

Browse files
committed
Phase 122: Optimize local variables with auto and declare-on-first-use
Convert ~60 local variable declarations in lvm.cpp VM hot path to use `auto` type deduction and declare-on-first-use pattern: VM dispatch loop (~45 opcodes): - StkId ra = RA(i) → auto ra = RA(i) - TValue *ptr = func() → auto *ptr = func() - int/unsigned val = func() → auto val = func() - Type *obj = cast() → auto *obj = cast() Lambda optimizations (6 lambdas): - op_arithf_aux, op_arith_aux: auto for ra, i1, i2 - op_bitwiseK, op_bitwise: auto for ra, v1, v2, i2 Benefits: - Cleaner, more maintainable code - Type changes propagate automatically - Follows C++23 best practices - Declare-on-first-use improves scope clarity Performance: 4.40s avg (5 runs) Target: ≤4.33s (within variance) Tests: All pass ✓ Files modified: src/vm/lvm.cpp (~60 optimizations)
1 parent 6de1a48 commit 98eafa5

File tree

1 file changed

+148
-152
lines changed

1 file changed

+148
-152
lines changed

0 commit comments

Comments
 (0)