diff options
author | vallentin <mail@vallentin.dev> | 2022-04-19 20:28:15 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-09-19 12:33:25 +0200 |
commit | 78db19000dd5a306b01cea4de1c3327b53ff2db4 (patch) | |
tree | 7139be5e31d72d6e164f2e48a6f93147b992e298 /askama_derive/src | |
parent | 1f74828931af0e509e2a676c6d61cff32f23b409 (diff) | |
download | askama-78db19000dd5a306b01cea4de1c3327b53ff2db4.tar.gz askama-78db19000dd5a306b01cea4de1c3327b53ff2db4.tar.bz2 askama-78db19000dd5a306b01cea4de1c3327b53ff2db4.zip |
Skip caching calls (Resolves #667)
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 5921609..e8d15f6 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -1196,11 +1196,12 @@ impl<'a> Generator<'a> { expr_buf.buf, self.input.escaper ), }; + let is_cacheable = !matches!(s, Expr::Call(..)); use std::collections::hash_map::Entry; let id = match expr_cache.entry(expression.clone()) { - Entry::Occupied(e) => *e.get(), - Entry::Vacant(e) => { + Entry::Occupied(e) if is_cacheable => *e.get(), + e => { let id = self.named; self.named += 1; @@ -1209,7 +1210,10 @@ impl<'a> Generator<'a> { buf_expr.write(&expression); buf_expr.writeln(",")?; - e.insert(id); + if let Entry::Vacant(e) = e { + e.insert(id); + } + id } }; |