fix: Add tail recursion where it's possible but missing #51
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.
See #46
Summary
This is partially extracted from #46 and one other opportunity where tail recursion was missing. The changes have been carried over one-by-one and split up.
One change is missing (
UnionAcc
) since it doesn't trigger a tail recursion case in TypeScript, since it wasn't on a single type, i.e. non-mutually recursive type alias, but on several types, and hoisted too far. So, that change hasn't been carried over. The benchmarks also seem to confirm that that change isn't relevant for this PR.(Note: In general, the benchmarks, when
selection
is run in isolation, give a good indicator of whether tail recursion is helping)In some of these cases, tail recursion hasn't increased performance, but the opportunity to add them is good nonetheless.
Set of changes
_getPossibleTypeSelectionRec
tail recursivegetInputObjectTypeRec
tail recursive_getVariablesRec
tail recursive