FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Common subexpression elimination · Issue #687 · purescript/purescript · GitHub

Common subexpression elimination #687

Description

This would need some thinking about, but it'd be really nice if we could improve the likes of this:

var ap = function (__dict_Monad_14) {
    return function (f) {
        return function (a) {
            return $greater$greater$eq(__dict_Monad_14["__superclass_Prelude.Bind_1"]())(f)(function (_2) {
                return $greater$greater$eq(__dict_Monad_14["__superclass_Prelude.Bind_1"]())(a)(function (_1) {
                    return $$return(__dict_Monad_14)(_2(_1));
                });
            });
        };
    };
};

into something like this:

var ap = function (__dict_Monad_14) {
    var __dict_Monad_14_Bind = __dict_Monad_14["__superclass_Prelude.Bind_1"]()
    var $greater$greater$eq_1 = $greater$greater$eq(__dict_Monad_14_Bind);
    var $$return_1 = $$return(__dict_Monad_14);
    return function (f) {
        return function (a) {
            return $greater$greater$eq_1(f)(function (_2) {
                return $greater$greater$eq_1(a)(function (_1) {
                    return $$return_1(_2(_1));
                });
            });
        };
    };
};

(Essentially declaring all instance related members and superclass instances as local variables as soon as is possible.)

Apart from improving readability somewhat, using the local $greater$greater$eq_1 over $greater$greater$eq(__dict_Monad_14["__superclass_Prelude.Bind_1"]()) everywhere should add up to a nice performance boost too. Most of optimisations I worked on for instances were to make constructing instances cheaper as they were the largest overhead, if we can reduce the number of constructions that's even better!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL