Commit fc7f7c4
Phase 2F: API Table Access Helpers (lapi.cpp) - Static Function Elimination
Converted 3 static table access helper functions to lua_State private methods:
- auxgetstr() → lua_State::auxGetStr()
- auxsetstr() → lua_State::auxSetStr()
- getGlobalTable() → lua_State::getGlobalTable()
**Changes**:
- Added 3 private method declarations to lua_State class (lstate.h)
- Added 5 friend function declarations for public API functions
- Converted static functions to member methods (lapi.cpp)
- Updated 6 call sites across 5 API functions
**Function Details**:
- auxgetstr() → auxGetStr(const TValue *t, const char *k): Gets value from
table using string key, handles fast path and metamethod fallback
- auxsetstr() → auxSetStr(const TValue *t, const char *k): Sets value in
table using string key, handles fast path and metamethod fallback
- getGlobalTable() → getGlobalTable(TValue *gt): Retrieves global table
from registry[LUA_RIDX_GLOBALS]
**Friend Functions** (need access to table access helpers):
- lua_getglobal() - gets global variable by name
- lua_getfield() - gets table field by string key
- lua_setglobal() - sets global variable by name
- lua_setfield() - sets table field by string key
- lua_load() - loads chunk and sets up global table as first upvalue
**Call Sites Updated**: 6 locations across 5 API functions
- lua_getglobal: calls getGlobalTable() and auxGetStr()
- lua_getfield: calls auxGetStr()
- lua_setglobal: calls getGlobalTable() and auxSetStr()
- lua_setfield: calls auxSetStr()
- lua_load: calls getGlobalTable() to setup function environment
**Impact**: Table access helpers properly encapsulated. These functions handle
the common pattern of string-keyed table access with fast path optimization.
**Files Changed**: 2 files (lstate.h, lapi.cpp)
**Testing**: All tests pass ✅ (2.11s single run)
**Benchmark**: 5-run average = 2.12s ✅ (50% faster than 4.20s baseline!)
**Risk**: MEDIUM (core API functions, multiple call sites, but well-tested)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent bc662e2 commit fc7f7c4
2 files changed
+43
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
592 | | - | |
593 | | - | |
594 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
595 | 595 | | |
596 | | - | |
| 596 | + | |
597 | 597 | | |
598 | | - | |
599 | | - | |
600 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
601 | 601 | | |
602 | | - | |
| 602 | + | |
603 | 603 | | |
604 | 604 | | |
605 | 605 | | |
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
613 | | - | |
| 612 | + | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
616 | | - | |
| 616 | + | |
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
624 | | - | |
| 623 | + | |
| 624 | + | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
| 642 | + | |
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
| |||
761 | 761 | | |
762 | 762 | | |
763 | 763 | | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
768 | 768 | | |
769 | | - | |
770 | | - | |
| 769 | + | |
| 770 | + | |
771 | 771 | | |
772 | 772 | | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
777 | 777 | | |
778 | | - | |
| 778 | + | |
779 | 779 | | |
780 | 780 | | |
781 | 781 | | |
782 | 782 | | |
783 | 783 | | |
784 | | - | |
785 | | - | |
786 | | - | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
| |||
802 | 802 | | |
803 | 803 | | |
804 | 804 | | |
805 | | - | |
806 | | - | |
| 805 | + | |
| 806 | + | |
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
| |||
1012 | 1012 | | |
1013 | 1013 | | |
1014 | 1014 | | |
1015 | | - | |
| 1015 | + | |
1016 | 1016 | | |
1017 | 1017 | | |
1018 | 1018 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
763 | 775 | | |
764 | 776 | | |
765 | 777 | | |
| |||
0 commit comments