Commit def4d406a for llama.cpp
commit def4d406ae2c2f39573120d68730fbb7760b24bf
Author: a u s t i n <135388519+xarillian@users.noreply.github.com>
Date: Thu Oct 1 02:10:57 2026 -0600
jinja : skip copying loop scope unless a loop filter needs it (#29776)
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<value> filtered_items;
for (size_t i = 0; i < items.size(); ++i) {
- context loop_scope(scope);
-
value current = items[i];
std::function<void(context&)> 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()) {