perf(config): skip tera render for plain strings#9833
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces contains_template_syntax and render_str_if_template to optimize string processing by skipping Tera rendering for plain text. These helpers are integrated across backends, tasks, and configuration modules. The review feedback focuses on further performance gains by moving the template syntax check earlier in the execution flow to avoid expensive operations like asynchronous context fetching, context cloning, and Tera instance initialization. There are also suggestions to include missing imports for these new utility functions.
Greptile SummaryThis PR skips Tera template rendering for plain strings that contain none of the
Confidence Score: 5/5Safe to merge — the skip logic is guarded by a conservative marker check, and every plain-string fast path preserves all non-Tera side effects such as shell-style env parsing on task dependencies. All call sites that skip Tera do so only when none of {{, {%, or {# are present, which exactly matches Tera 1.20.1's block openers. The has_render_templates predicate in Task::render covers the same fields the render function actually writes to. The extraction of parse_shell_style_env into parse_plain_depends correctly reproduces the original dependency side-effect in the fast path. No issues were found that would cause incorrect output or missed rendering. No files require special attention. The most complex change is in src/task/mod.rs (has_render_templates + render refactor), but the predicate is complete and the ordering of store_raw_render_inputs relative to dep rendering now correctly saves truly-unrendered dependency snapshots. Important Files Changed
Reviews (5): Last reviewed commit: "style(task): satisfy clippy for template..." | Re-trigger Greptile |
### 🚀 Features - **(config)** add shell to watch_files run by @risu729 in [#9810](#9810) - **(spm)** add artifact bundle support by @ikesyo in [#9825](#9825) ### 🐛 Bug Fixes - **(aqua)** reject registry-invalid latest tags by @risu729 in [#9834](#9834) - **(patrons)** point sponsor link to https://en.dev by @jdx in [#9868](#9868) - **(vfox)** respect default inline shell in cmd.exec by @risu729 in [#9837](#9837) - github oauth device flow paths by @jasisk in [#9791](#9791) ### 📚 Documentation - Update Walkthrough guide by @thernstig in [#9853](#9853) ### ⚡ Performance - **(config)** skip tera render for plain strings by @risu729 in [#9833](#9833) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:rpm docker digest to d2471f2 by @renovate[bot] in [#9879](#9879) - update rust docker digest to 5b1e348 by @renovate[bot] in [#9880](#9880) - update ghcr.io/jdx/mise:deb docker digest to 0cde829 by @renovate[bot] in [#9878](#9878) - update ubuntu docker tag to resolute-20260421 by @renovate[bot] in [#9881](#9881) - update ghcr.io/jdx/mise:alpine docker digest to 2d0ea74 by @renovate[bot] in [#9877](#9877) - update rust crate phf to 0.13 by @renovate[bot] in [#9884](#9884) - update rust crate phf_codegen to 0.13 by @renovate[bot] in [#9883](#9883) ### 📦 Registry - use aqua backend for npm by @risu729 in [#9762](#9762) - add aqua for buck2 prereleases by @risu729 in [#9805](#9805) - add SonarQube CLI ([aqua:SonarSource/sonarqube-cli](https://github.com/SonarSource/sonarqube-cli)) by @3PeatVR in [#9824](#9824) ### New Contributors - @3PeatVR made their first contribution in [#9824](#9824) - @ikesyo made their first contribution in [#9825](#9825) - @thernstig made their first contribution in [#9853](#9853) ## 📦 Aqua Registry Updates ### New Packages (4) - [`SurgeDM/Surge`](https://github.com/SurgeDM/Surge) - [`roie/ovw`](https://github.com/roie/ovw) - [`so-dang-cool/sigi`](https://github.com/so-dang-cool/sigi) - [`vjeantet/alerter`](https://github.com/vjeantet/alerter) ### Updated Packages (2) - [`alltuner/mise-completions-sync`](https://github.com/alltuner/mise-completions-sync) - [`str4d/age-plugin-yubikey`](https://github.com/str4d/age-plugin-yubikey)
Summary
get_terasetup at render call sitesTera::render_strbehindsrc/tera.rs, and use guardedrender_strcalls after an early syntax check to avoid redundant re-checksWhy this is safe
{{,{%, or{#. That includes whitespace-trimmed forms like{{-,{%-, and{#-.Tera::render_strwould add and render a one-off raw template that returns the same plain string.Testing
cargo fmt --all -- --checkgit diff --checkrg -n '\.render_str\(' src --glob '*.rs'/home/risu/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin/cargo check --all-features/home/risu/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin/cargo clippy -- -D warnings/home/risu/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin/cargo test -p mise --bin mise tera::tests/home/risu/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin/cargo test -p mise --bin mise config::env_directive/home/risu/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin/cargo test -p mise --bin mise task::task_script_parser/home/risu/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin/cargo test -p mise --bin mise task::task_dep/home/risu/.rustup/toolchains/1.95.0-x86_64-unknown-linux-gnu/bin/cargo test -p mise --bin mise task::tests