Skip to content

Conversation

@NiceAndPeter
Copy link
Owner

No description provided.

Converted 4 remaining predicate functions from int to bool:
- iscleared() (gc_weak.cpp:52) - GC weak table predicate
- isneg() (lobject.cpp:207) - Sign checking predicate
- rawfinishnodeset() (ltable.cpp:1187) - Table insertion success check
- checkbuffer() (lzio.cpp:46) - Buffer validation predicate

Also updated call site in Table::setInt() to use bool variable.

This completes the boolean modernization initiative started in
Phases 113 and 117, bringing total bool conversions to 16 functions.

Testing:
- All tests pass (final OK !!!)
- Performance: 4.45s avg (within acceptable bounds)

Follows pattern from Phase 117 (5 predicates) and Phase 113 (7 predicates).
Converted 6 opportunities in ltests.cpp to use std::span accessors:
1. checkproto() - 4 range-based for loops using span accessors
2. listcode() - codeSpan iteration with index tracking
3. printcode() - codeSpan iteration with index tracking
4. listk() - constantsSpan iteration
5. listabslineinfo() - absLineInfoSpan iteration
6. lua_checkpc() - bounds check using codeSpan.data()

All conversions use existing span accessors from Phase 115-116:
- Proto::getCodeSpan()
- Proto::getConstantsSpan()
- Proto::getProtosSpan()
- Proto::getUpvaluesSpan()
- ProtoDebugInfo::getAbsLineInfoSpan()
- ProtoDebugInfo::getLocVarsSpan()

Benefits:
- Type-safe array access
- Cleaner range-based for loops
- Better intent expression

Testing:
- All tests pass (final OK !!!)
- Performance: 4.44s avg (vs 4.45s from Phase 120)
- Zero performance regression

This is part 1 of the std::span expansion effort (Option 2).
…Runtime)

Converted 9 additional patterns to use existing std::span accessors:

**Phase 122 - Compiler Code (7 conversions):**

funcstate.cpp:
1. registerlocalvar() - locVarsSpan initialization loop
2. searchupvalue() - upvaluesSpan search loop
3. allocupvalue() - upvaluesSpan initialization loop

lcode.cpp:
4. addk() - constantsSpan initialization loop
5. finaltarget() - codeSpan jump chain following
6. finish() - codeSpan instruction loop

parser.cpp:
7. addprototype() - protosSpan initialization loop

**Phase 123 - Runtime Code (2 conversions):**

lfunc.cpp:
8. Proto::getLocalName() - locVarsSpan range-based for loop

lvm.cpp:
9. lua_State::pushClosure() - upvaluesSpan range-based for loop

All conversions use existing span accessors from Phase 115-116:
- Proto::getCodeSpan()
- Proto::getConstantsSpan()
- Proto::getProtosSpan()
- Proto::getUpvaluesSpan()
- ProtoDebugInfo::getLocVarsSpan()

Benefits:
- Type-safe array access throughout compiler and runtime
- Cleaner range-based for loops where applicable
- Better bounds safety with std::span
- More idiomatic modern C++23 code

Testing:
- All tests pass (final OK !!!)
- Performance: 4.61s avg (within acceptable bounds)
- Total std::span conversions: 15 (Phase 121: 6 + Phase 122: 7 + Phase 123: 2)

This completes the std::span expansion effort (Option 2) with 15 new
call sites converted beyond the original Phase 115-116 accessor additions.
@NiceAndPeter NiceAndPeter merged commit 1952a0f into main Nov 21, 2025
11 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants