aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar max <gmx.sht@gmail.com>2023-12-08 14:40:24 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2024-01-17 17:58:53 +0100
commit2c7759c0d0534dd9903ebd97b13c4c44320a9aad (patch)
treef3ba5d09e81bb3fdecd3f564adeeefa23100ed8d /askama_derive
parent411efb89278305a0c38f1f28924a02e03b161679 (diff)
downloadaskama-2c7759c0d0534dd9903ebd97b13c4c44320a9aad.tar.gz
askama-2c7759c0d0534dd9903ebd97b13c4c44320a9aad.tar.bz2
askama-2c7759c0d0534dd9903ebd97b13c4c44320a9aad.zip
Improve performance of `find_used_templates`
Signed-off-by: max <gmx.sht@gmail.com>
Diffstat (limited to 'askama_derive')
-rw-r--r--askama_derive/src/input.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index 7314d2e..215d060 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -119,8 +119,13 @@ impl TemplateInput<'_> {
while let Some(nodes) = nested.pop() {
for n in nodes {
let mut add_to_check = |path: PathBuf| -> Result<(), CompileError> {
- let source = get_template_source(&path)?;
- check.push((path, source));
+ if !map.contains_key(&path) {
+ // Add a dummy entry to `map` in order to prevent adding `path`
+ // multiple times to `check`.
+ map.insert(path.clone(), Parsed::default());
+ let source = get_template_source(&path)?;
+ check.push((path, source));
+ }
Ok(())
};