Repository navigation
Guarantee compile-time initialization of scan arena tables - #311
Merged
thweetkomputer merged 1 commit intoOct 11, 2026
Merged
thweetkomputer merged 1 commit into
thweetkomputer merged 1 commit into
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The scan arena size-class tables should be guaranteed to initialize at compile time. This PR contains only commit
530faea27c738b89a4a10e303c41e456118c7001.Behavior before and after
Previously, the tables were defined as
inline const, and the lookup builder readkClassSizes, leaving constant initialization without an explicit language-level guarantee. Both definitions are nowinline constexpr, so the compiler enforces constant initialization. Size-class values and allocation behavior remain unchanged.Implementation
BuildClassLookup()builds a local constexpr size array usingBuildClassSizes(). Both table definitions useinline constexpr.Design decisions and alternatives
Use compile-time evaluation of the existing builders, preserving their shared size-class calculation and avoiding runtime initialization dependencies.
Documentation and comments
No architectural claim, public API behavior, ownership model, or durable format changes; no architecture update is required. The change is confined to the table builder and definitions.
Test plan
Passed in an isolated worktree on ARM64 with GCC 13.3 and Clang 18.1:
The compiler checks use the existing dependency headers read-only. Full build and runtime tests were not run locally.
Risk assessment
Low: the size-class calculation is unchanged. Both tested compilers accept the constexpr definitions and evaluate their initializers successfully.
Rollback plan
Revert this commit.
Reviewer guide
Review
BuildClassLookup()and the two table definitions ininclude/lavik/storage/scan_hash_map.h.Follow-up work
None planned.