Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add tail recursion where it's possible but missing #51

Merged
merged 4 commits into from
Feb 3, 2024

Conversation

kitten
Copy link
Member

@kitten kitten commented Feb 3, 2024

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

  • Make _getPossibleTypeSelectionRec tail recursive
  • Make getInputObjectTypeRec tail recursive
  • Make _getVariablesRec tail recursive

kitten and others added 4 commits February 3, 2024 09:47
This doesn't seem to affect `selection` benchmarks,
but is technically more correct since tail-recursion
is possible here.

Co-authored-by: deathemperor <[email protected]>
Co-authored-by: HaiNNT <[email protected]>
More correct, as per tail recursion in other
places, but `variables.ts` didn't get much
attention before

Co-authored-by: deathemperor <[email protected]>
Co-authored-by: HaiNNT <[email protected]>
More correct, as per tail recursion in other
places, but `variables.ts` didn't get much
attention before
Copy link

changeset-bot bot commented Feb 3, 2024

🦋 Changeset detected

Latest commit: 235df22

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kitten kitten merged commit cdd6370 into main Feb 3, 2024
3 checks passed
@kitten kitten deleted the fix/46-tail-recursion branch February 3, 2024 10:43
@github-actions github-actions bot mentioned this pull request Feb 3, 2024
@kitten kitten added this to the Are We Fast Yet? milestone Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants