Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.43k stars 279 forks source link

Optimize `find_value_in_for_loop` when no `Value` is found #865

Closed harrisonkaiser closed 3 months ago

harrisonkaiser commented 10 months ago

In the event that a for loop iterates over Values and also referes to elements not defined by the for loop, find_value_in_for_loop would needlessly call ForLoop::get_current_value for each of those lookups.

ForLoop::get_current_value can be expensive, potentially incurring a clone of a possibly large Value.

This change moves the get_current_value call so that we only clone a Value when needed.