feat: use private static fields to store constant typeParameters where possible#1606
Merged
ChrisPulman merged 1 commit intoreactiveui:mainfrom Dec 2, 2023
Merged
Conversation
private static fields to store constant typeParameters where possibleprivate static fields to store constant typeParameters & genericTypes where possible
private static fields to store constant typeParameters & genericTypes where possibleprivate static fields to store constant typeParameters where possible
c5b222b to
680f3b9
Compare
Member
|
Seems legit, @clairernovotny? |
680f3b9 to
638bef2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1606 +/- ##
=======================================
Coverage 87.81% 87.81%
=======================================
Files 33 33
Lines 2347 2347
Branches 294 294
=======================================
Hits 2061 2061
Misses 207 207
Partials 79 79 ☔ View full report in Codecov by Sentry. |
1e659da to
33f669b
Compare
8173af0 to
d912119
Compare
d912119 to
a54d24e
Compare
Member
|
@ChrisPulman Any objections to this PR? |
Member
I am currently in India, but I will check it this evening and merge it if it's fitting to our requirements, thank you. |
Member
|
All looks good, thank you Tim |
ChrisPulman
approved these changes
Dec 2, 2023
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Modify source generator to use
private static readonlyfields to store thetypeParameterarrays, saving the allocations for each request.Array.Emptyis used - feat: generate code that usesArray.Emptywhere possible #1599private staticfields are generated beside its respective method, this could be moved to the start of the class if requested.HashSetof each member in scope to accidental name collisions. Fields will have names like_typeParameters3incrementing for each field generated.Uses nullable coalescing assignment if one of the method parameters uses type arguments. This is done as we may not be able to access it from outside the method scope making the array initialization invalid.It should be safe to initialize and set the static arrays in multithreaded contexts as setting references are thread safe in C#.Edit:
typeof(T)will be different for each usage of T so it isn't possible to have a reusable_genericTypearray. This can also cause issues for_typeParameter.GenerateTypeParameterExpressionensures that each parameter doesn't contain a generic type parameter, falling back to the current solution if it detects one.See #1598