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

Avoid cloning the Render Context #661

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

cmrschwarz
Copy link
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

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
Copy link
Owner

sunng87 commented Jul 15, 2024

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
9 checks passed
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