Skip to content

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

Description

@jfmengels

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions