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

Allow inlining one-line functions #139

Merged
merged 1 commit into from
May 13, 2022
Merged

Conversation

jwatzman
Copy link
Contributor

This implements the simplest possible implementation of inlining
functions. It only supports a function consisting of a single return,
when it has been explicitly named as i_whatever. Basically, this works
in cases where you might want to use a macro, excpet this gives the
minifier full visibility through it.

The simplicity of this implementation means that it's likely possible to
get into trouble by marking certain functions as to-be-inlined. In
particular, I'm pretty sure the following will break it:

  • inlining overloaded functions
  • inlining a function into a scope which has a local shadowing a global,
    where the inlined function refers to that global (though this will
    also break a macro)

README.md Show resolved Hide resolved
src/rewriter.fs Outdated Show resolved Hide resolved
This implements the simplest possible implementation of inlining
functions. It only supports a function consisting of a single `return`,
when it has been explicitly named as `i_whatever`. Basically, this works
in cases where you might want to use a macro, excpet this gives the
minifier full visibility through it.

The simplicity of this implementation means that it's likely possible to
get into trouble by marking certain functions as to-be-inlined. In
particular, I'm pretty sure the following will break it:
- inlining overloaded functions
- inlining a function into a scope which has a local shadowing a global,
  where the inlined function refers to that global (though this will
  also break a macro)
@laurentlb laurentlb merged commit 60cf07b into laurentlb:master May 13, 2022
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.

None yet

2 participants