Commit bc662e2
Phase 2E: API Helper Function (lapi.cpp) - Static Function Elimination
Converted 1 static function to lua_State private method:
- reverse() → lua_State::reverseStack()
**Changes**:
- Added 1 private method declaration to lua_State class (lstate.h)
- Added 1 friend function declaration for lua_rotate (public API)
- Converted static function to member method (lapi.cpp)
- Updated 3 call sites in lua_rotate to use L->reverseStack()
**Function Details**:
- reverse() → reverseStack(StkId from, StkId to): Reverses stack elements
between two positions, used as a building block for lua_rotate's rotation
algorithm (AB → BA via (A^r · B^r)^r)
**Friend Function** (needs access to API helper):
- lua_rotate() - public API that rotates stack elements, calls reverseStack 3 times
**Call Sites Updated**: 3 call sites in lua_rotate
- Reverse the prefix with length 'n'
- Reverse the suffix
- Reverse the entire segment
**Impact**: Stack manipulation helpers now properly encapsulated as lua_State
private methods. Simple, focused change to a single helper function.
**Files Changed**: 2 files (lstate.h, lapi.cpp)
**Testing**: All tests pass ✅ (2.14s single run)
**Benchmark**: 5-run average = 2.13s ✅ (49% faster than 4.20s baseline!)
**Risk**: LOW (simple helper, single use case, well-tested)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 038820e commit bc662e2
2 files changed
+11
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
180 | | - | |
181 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
757 | 763 | | |
758 | 764 | | |
759 | 765 | | |
| |||
0 commit comments