From def4d406ae2c2f39573120d68730fbb7760b24bf Mon Sep 17 00:00:00 2001 From: a u s t i n <135388519+xarillian@users.noreply.github.com> Date: Thu, 1 Oct 2026 02:10:57 -0600 Subject: [PATCH] jinja : skip copying loop scope unless a loop filter needs it (#29776) --- common/jinja/runtime.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/jinja/runtime.cpp b/common/jinja/runtime.cpp index a44d63c0c..b8a69995b 100644 --- a/common/jinja/runtime.cpp +++ b/common/jinja/runtime.cpp @@ -537,8 +537,6 @@ value for_statement::execute_impl(context & ctx) const { std::vector filtered_items; for (size_t i = 0; i < items.size(); ++i) { - context loop_scope(scope); - value current = items[i]; std::function scope_update_fn = [](context &) { /* no-op */}; @@ -584,6 +582,7 @@ value for_statement::execute_impl(context & ctx) const { } if (select_expr && test_expr) { + context loop_scope(scope); scope_update_fn(loop_scope); value test_val = test_expr->execute(loop_scope); if (!test_val->as_bool()) {