perf: Flatten internal Lazy<bool> fields in UnionCaseArgInfo#299
Open
dimension-zero wants to merge 1 commit into
Open
perf: Flatten internal Lazy<bool> fields in UnionCaseArgInfo#299dimension-zero wants to merge 1 commit into
dimension-zero wants to merge 1 commit into
Conversation
The seven boolean-valued fields on `UnionCaseArgInfo` (`IsRest`, `AppSettingsCSV`, `IsMandatory`, `IsInherited`, `IsUnique`, `IsHidden`, `GatherAllSources`) were each wrapped in `Lazy<bool>` even though their bodies only inspect already-cached attribute arrays. Each wrapper allocated a heap object per case and `checkUnionArgInfo` forced every one on the default construction path, so the deferral was buying nothing. Make them strict `bool`. The more complex `Lazy<_>` fields whose bodies raise validation errors (`CustomAssignmentSeparator`, `IsGatherUnrecognized`, `CliPosition`, `MainCommandName`, `ParameterInfo`, etc.) remain `Lazy<_>` so error-emission timing is unchanged for `checkStructure=false` consumers. The public `ArgumentCaseInfo` type keeps `Lazy<bool>` for binary compatibility — `ToArgumentCaseInfo()` wraps the strict bools with `lazy ...` at the boundary.
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.
Summary
Seven boolean-valued fields on the internal
UnionCaseArgInfowere eachLazy<bool>even though their bodies only inspect already-cached attribute arrays. Make them strictbool:IsRest,AppSettingsCSV,IsMandatory,IsInherited,IsUnique,IsHidden,GatherAllSourcesLazy<_>fields whose bodies raise validation errors (CustomAssignmentSeparator,IsGatherUnrecognized,CliPosition,MainCommandName,ParameterInfo, etc.) remainLazy<_>so error-emission timing is unchanged for thecheckStructure=falseconsumers.Public
ArgumentCaseInfokeepsLazy<bool>for binary compatibility —ToArgumentCaseInfo()wraps the strict bools withlazy ...at the boundary.Why
Each
Lazy<bool>was a heap allocation that boxed a primitive, with no deferral benefit —checkUnionArgInfoforces every one on the default construction path anyway. The criticism in the original review was that the lazy graph wasn't carrying its weight; this commit flattens the seven flags that are safe to flatten without changing observable behaviour.Test plan
dotnet build -c Release— clean (0 warnings)dotnet test -c Release— 112/112 pass