Skip to content

Avoid cloning the Render Context #661

Merged
sunng87 merged 3 commits into
sunng87:masterfrom
cmrschwarz:avoid_context_clone_v2
Jul 15, 2024
Merged

Avoid cloning the Render Context #661
sunng87 merged 3 commits into
sunng87:masterfrom
cmrschwarz:avoid_context_clone_v2

Conversation

@cmrschwarz

Copy link
Copy Markdown
Contributor

Inspired by your comment in #624 I think I came up with a much better way to fix the problem.

The reason why we couldn't get the correct lifetime is that dev mode dynamically creates new templates during rendering. So I just fixed that problem instead by making dev mode load all templates upfront.

That way we now no longer have to clone the RenderContext 🎉 .

Incidentally this also solves the issue that dev mode would reload a template from disk each time it hits it,
including in some nested {{#each}}. I think this probably more than outweighs the drawback of having to preload all registered templates. We could optimize this further in the future, though it may even be good enough as is.

Resolves #624.

@cmrschwarz cmrschwarz force-pushed the avoid_context_clone_v2 branch from 3943117 to 1adbc0a Compare July 15, 2024 10:02
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 81.548% (+0.1%) from 81.402%
when pulling 1adbc0a on cmrschwarz:avoid_context_clone_v2
into 5848265 on sunng87:master.

@sunng87

sunng87 commented Jul 15, 2024

Copy link
Copy Markdown
Owner

Awesome! This is great step forward!

I will create a benchmark for partials to measure this.

@sunng87 sunng87 merged commit 080b5e0 into sunng87:master Jul 15, 2024
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.

Reuse RenderContext after executing partial

3 participants