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

Be smarter with when to wrap in IIFE #37

Merged
merged 5 commits into from
Dec 19, 2023

Conversation

planttheidea
Copy link
Owner

Reason for change

The original setup was an introspection of both contents and ancestral tree, which led to wrapping things in IIFEs when not necessary. Because there is a (tiny, but present) cost to IIFEs vs pure inline logic, more intelligence is warranted.

Change

Modify shouldWrapInClosure to focus exclusively on the callsite's scope. This involves:

  • Recursion to verify ancestral tree to bail out on first wrap case, to better handle usage in a nested expression scenario
  • Checking the body size of the function parent to determine if there are any other operations within the scope

@planttheidea planttheidea merged commit 111cfa7 into master Dec 19, 2023
@planttheidea planttheidea deleted the enhancement/smarter-iife-wrapper-logic branch December 19, 2023 16:07
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.

1 participant