Repository navigation
Share enum initialization by underlying width - #132
Merged
Merged
Conversation
Read enum values through their unsigned storage type to share ordering and continuity checks across enum types.
xin9le
approved these changes
Nov 24, 2026
xin9le
left a comment
Owner
There was a problem hiding this comment.
Thanks! That's a really nice idea, and I appreciate your contribution!
Actually, I'd been thinking about determining s_isContinuous inside .ToOrderedMembers() too. But I didn't like how it looked to return it via an out parameter, so I held off on it. Seeing your PR made me realize I should've given it another look.
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.
Share enum initialization by underlying width
Continues #77 by sharing enum member ordering and continuity checks across types with the same backing width. Adds regression coverage for signed ranges and alias selection.
Results
.NET 11.0.0 on Windows x64, Release. Medians from 15 fresh processes per variant. First use measures
FastEnum.IsContinuous<T>(). Both benchmark builds include the separate Native AOT fix in #131. The control starts atb488d4d.Median first-use allocations fell by 20 B/type under JIT and 14 B/type under Native AOT. One 128-type JIT run allocated more than the control. Warm lookups allocated 0 B/op.
Memory breakdown at 128 enum types
A separate memory probe used 11 fresh processes per variant. JIT machine-code totals were identical across three EventPipe traces per variant.
.rdata).data)Estimated JIT private native data grew by 964 → 972 KiB during initialization, with overlapping run ranges. Native AOT private commit grew by 1,768 KiB in both variants.
All 635 tests passed on each of .NET 10 and .NET 11.