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

Stop freezing the static environment hashes to allow Proc memoization #1623

Merged
merged 1 commit into from
Sep 14, 2022

Conversation

dylanahsmith
Copy link
Contributor

Problem

I noticed for Shopify's storefront rendering that we are hacking around the fact that the static environments get frozen by overriding the Liquid::Context#initialize and Liquid::Context#new_isolated_subcontext to mimic the same feature. I suspect the reason for that hack is that it allows for lazy loading by assigning a Proc in the environment, which doesn't work with Liquid::Context#static_environments due to the freezing of its Hashes in Liquid::Context#initialize.

Solution

Remove the freezing of the static environments hashes in Liquid::Context#initialize. Instead, we just treat it as semantically static, so that it supports memoization. This is similar to how liquid values tend to be immutable, even though they may have internal mutations for memoizing lazy loads.

@dylanahsmith dylanahsmith merged commit cab08cf into master Sep 14, 2022
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.

2 participants