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

[Static optimization] Concatenate adjacent static blocks #4096

Open
nolanlawson opened this issue Mar 22, 2024 · 0 comments
Open

[Static optimization] Concatenate adjacent static blocks #4096

nolanlawson opened this issue Mar 22, 2024 · 0 comments

Comments

@nolanlawson
Copy link
Collaborator

For a template like this:

<template>
  <div>one</div>
  <span>two</span>
  <pre>three</pre>
</template>

... we currently compile this into:

const $fragment1 = parseFragment`<div${3}>one</div>`;
const $fragment2 = parseFragment`<span${3}>two</span>`;
const $fragment3 = parseFragment`<pre${3}>three</pre>`;
function tmpl($api, $cmp, $slotset, $ctx) {
  const { st: api_static_fragment } = $api;
  return [
    api_static_fragment($fragment1, 1),
    api_static_fragment($fragment2, 3),
    api_static_fragment($fragment3, 5),
  ];
}

Ideally, though, we should be able to combine these adjacent static fragments into one big fragment:

const $fragment1 = parseFragment`<div${3}>one</div><span${3}>two</span><pre${3}>three</pre>`;

This should theoretically have a perf benefit, because we are calling cloneNode(true) fewer times and cloning more nodes with each go.

This might be a bit complex to support in the compiler and at runtime, but it seems doable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant