-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
Skip caching calls (Resolves #667) #668
Conversation
askama_shared/src/generator.rs
Outdated
@@ -1058,11 +1058,12 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { | |||
expr_buf.buf, self.input.escaper | |||
), | |||
}; | |||
let is_cacheable = !matches!(s, Expr::Call(..)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this doesn't need to be a "deep" check. E.g. foo().0
should still be uncachable, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, you're right. Guess my quick fix, was too quick. I'll fix it later 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I review before you fix it or do you want to fix it before I review? Not sure what's more appropriate here.
393060f
to
06ab17f
Compare
Rebased on main. I added |
@vallentin, I hope it's okay that I took this over. :) |
Thanks! |
This is just a quick fix to address #667, and open up discussion.
Should we take any assumptions about interior mutability, statics and side-effects? i.e. never cache calls. Someone could potentially even make a "funky"
impl Deref
, making caching field accesses "wrong".Alternative suggestion, we could introduce a config to disable caching.
(I'll add tests, update docs, etc. when I know whether we want a config or just take no assumptions and not cache)
New behavior:
Now generates: