Repository navigation
Generate GetDefaultMappings as an array instead of an iterator - #1737
Open
tmilnthorp wants to merge 2 commits into
Open
tmilnthorp wants to merge 2 commits into
tmilnthorp wants to merge 2 commits into
Conversation
Each yield-return method compiles to a hidden iterator class. Returning an array removes 129 of those classes (-194 KB in the net10.0 DLL) and lets QuantityInfo size its unit array up front. The return type is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1737 +/- ##
========================================
- Coverage 98% 98% -1%
========================================
Files 515 515
Lines 24092 22361 -1731
========================================
- Hits 23692 21961 -1731
Misses 400 400
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Oct 6, 2026
This branch has not been deployed
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.
Each generated
GetDefaultMappings()usedyield return. The compiler turns each one into a hidden iterator class, so that's 129 extra classes in the DLL. This PR generates an array instead. The return type staysIEnumerable<UnitDefinition<TUnit>>, so there's no API change. The generated code reads the same apart from the array syntax.QuantityInfocalls.Select(...).ToArray()on the mappings. Given an array, LINQ knows the count up front and allocates the result once.The generator change and the regenerated code are separate commits.
ToString()(cold process)Hot-path benchmarks for
ToString,Parse, conversions, arithmetic andQuantityInfoLookuplookups are unchanged within noise.🤖 Generated with Claude Code
https://claude.ai/code/session_012XKhDsyHDc5BHrmibxScqG