Skip to content

Combine per-element reactive bindings into single effects - #820

Open
wouterlucas wants to merge 1 commit into
cached-computedfrom
combine-element-effects
Open

wouterlucas wants to merge 1 commit into
cached-computedfrom
combine-element-effects

Conversation

@wouterlucas

Copy link
Copy Markdown
Contributor

Stacked on #819. Groups each element's reactive bindings (:props, content interpolation) into one codegen effect entry instead of one per binding, cutting registered effects from #bindings to #dynamic-elements.

What changed:

  • src/lib/codegenerator/generator.js: generateElementCode and the prop loop in generateComponentCode buffer statements and flush one combined entry via a new flushElementEffects helper.
  • :for safety: buffered statements are split by the existing scope regex, so iteration-only bindings merge into one inner per-item effect while outer-scope bindings stay in the outer loop wrapper (no O(n) regression for mixed bindings).
  • Single-statement output is byte-identical to before.

Tests: updated 4 goldens (2->1, 3->1, 2->1, 2->1); multi-element cases unchanged (Poster stays at 4). New codegen test pins inner/outer split-and-merge in loops; new renderComponent tests pin effect counts (3 bindings -> 2 effects) and mixed loop updates. Full suite 1550/1550, eslint clean.

@github-actions

Copy link
Copy Markdown

Benchmark comparison

Timing Change
Synchronous generation n/a
Total time to idle -0.47%

Negative means faster. Informational results; small changes can be measurement noise.

Full report · Workflow run

Head: fb1783fa8f28 · Base: 6e255578aab1

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant