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

Optimization false negative: inlineWrappedFunctions doesn't work for function aliases #101

Open
jfmengels opened this issue Aug 17, 2022 · 0 comments

Comments

@jfmengels
Copy link
Contributor

jfmengels commented Aug 17, 2022

The inlineWrappedFunctions transformer transforms

var _String_startsWith = F2(function(sub, str)
{
	return str.indexOf(sub) === 0;
});
-- to
var _String_startsWith_fn = function (sub, str) {
    return str.indexOf(sub) === 0;
}, _String_startsWith = F2(_String_startsWith_fn);

But elm/core's String.startsWith is implemented as startsWith = Elm.Kernel.String.startsWith in Elm (var $elm$core$String$startsWith = _String_startsWith; in JS).

The transformer currently ignores these kinds of functions, meaning that they don't benefit from the same optimization. I think the transformer could try to be smarter by noticing this is an alias to a previously optimized function, and split it up as well.

var $elm$core$String$startsWith = _String_startsWith;
-->
var $elm$core$String$startsWith = _String_startsWith, $elm$core$String$startsWith_fn = _String_startsWith_fn;

and then have the transformer use the most optimized version for the newly optimized functions also.

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

No branches or pull requests

1 participant