diff options
author | René Kijewski <rene.kijewski@fu-berlin.de> | 2022-09-17 03:48:10 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-09-19 12:33:25 +0200 |
commit | 7edb3d4685aff00880906873db4eb9f649a077d9 (patch) | |
tree | bf9fe8d3c618d21556ea6a275e8b7e11ccc6b819 /askama_derive/src/generator.rs | |
parent | 78db19000dd5a306b01cea4de1c3327b53ff2db4 (diff) | |
download | askama-7edb3d4685aff00880906873db4eb9f649a077d9.tar.gz askama-7edb3d4685aff00880906873db4eb9f649a077d9.tar.bz2 askama-7edb3d4685aff00880906873db4eb9f649a077d9.zip |
Add Expr::is_cachable()
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r-- | askama_derive/src/generator.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index e8d15f6..7077cfd 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -7,7 +7,7 @@ use crate::CompileError; use proc_macro::TokenStream; use quote::{quote, ToTokens}; -use std::collections::HashMap; +use std::collections::hash_map::{Entry, HashMap}; use std::path::{Path, PathBuf}; use std::{cmp, hash, mem, str}; @@ -1196,11 +1196,9 @@ 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) if is_cacheable => *e.get(), + Entry::Occupied(e) if s.is_cachable() => *e.get(), e => { let id = self.named; self.named += 1; |