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

Improve serialization of bound functions with circular references #75

Open
overlookmotel opened this issue Jan 31, 2021 · 1 comment
Open
Labels
optimization Improvement to performance or output

Comments

@overlookmotel
Copy link
Owner

overlookmotel commented Jan 31, 2021

Current serialization of functions with circular references is very verbose:

Input:

export default function f() {}
f.bound = f.bind({});

Serialized output:

const bindingBound_f = (() => {
    let bound;
    return [
      (...vars) => bound(...vars),
      _bound => bound = _bound
    ];
  })(),
  Object$0 = Object,
  f = Object$0.assign(
    function f() {},
    {
      bound: Object$0.defineProperties(
        bindingBound_f[0],
        {name: {value: "bound f"}}
      )
    }
  );
bindingBound_f[1](f.bind({}));
export default f;

This works, but could be a great deal shorter. Output should be identical to the input.

@overlookmotel overlookmotel added the feature New feature or request label Jan 31, 2021
@overlookmotel overlookmotel added optimization Improvement to performance or output and removed feature New feature or request labels Feb 10, 2021
@overlookmotel
Copy link
Owner Author

This will be easier to solve once two-phase serialization is implemented (#426).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Improvement to performance or output
Projects
None yet
Development

No branches or pull requests

1 participant