mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-18 03:31:41 +00:00
Reduce memory usage of the context restoration compiled at the end of for loops
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# 3.28.0 (2026-XX-XX)
|
# 3.28.0 (2026-XX-XX)
|
||||||
|
|
||||||
|
* Reduce memory usage and speed up the context restoration compiled at the end of `for` loops
|
||||||
* Report the column number in syntax errors and expose it via `Error::getTemplateColumn()`
|
* Report the column number in syntax errors and expose it via `Error::getTemplateColumn()`
|
||||||
* Track the source offset of each token and expose it via `Token::getOffset()`
|
* Track the source offset of each token and expose it via `Token::getOffset()`
|
||||||
* Fix nested `block()` calls to resolve against the overriding template when a block rendered through `block(name, template)` calls `parent()`
|
* Fix nested `block()` calls to resolve against the overriding template when a block rendered through `block(name, template)` calls `parent()`
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ class ForNode extends Node
|
|||||||
$compiler->raw(");\n");
|
$compiler->raw(");\n");
|
||||||
|
|
||||||
// keep the values set in the inner context for variables defined in the outer context
|
// keep the values set in the inner context for variables defined in the outer context
|
||||||
$compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
|
$compiler
|
||||||
|
->write("\$context = array_intersect_key(\$context, \$_parent);\n")
|
||||||
|
->write("\$context += \$_parent;\n")
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) {
|
|||||||
}
|
}
|
||||||
\$_parent = \$context['_parent'];
|
\$_parent = \$context['_parent'];
|
||||||
unset(\$context['_seq'], \$context['key'], \$context['item'], \$context['_parent']);
|
unset(\$context['_seq'], \$context['key'], \$context['item'], \$context['_parent']);
|
||||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
\$context = array_intersect_key(\$context, \$_parent);
|
||||||
|
\$context += \$_parent;
|
||||||
EOF
|
EOF
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -119,7 +120,8 @@ foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
|||||||
}
|
}
|
||||||
\$_parent = \$context['_parent'];
|
\$_parent = \$context['_parent'];
|
||||||
unset(\$context['_seq'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
unset(\$context['_seq'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
||||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
\$context = array_intersect_key(\$context, \$_parent);
|
||||||
|
\$context += \$_parent;
|
||||||
EOF
|
EOF
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -161,7 +163,8 @@ foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
|||||||
}
|
}
|
||||||
\$_parent = \$context['_parent'];
|
\$_parent = \$context['_parent'];
|
||||||
unset(\$context['_seq'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
unset(\$context['_seq'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
||||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
\$context = array_intersect_key(\$context, \$_parent);
|
||||||
|
\$context += \$_parent;
|
||||||
EOF
|
EOF
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -210,7 +213,8 @@ if (!\$context['_iterated']) {
|
|||||||
}
|
}
|
||||||
\$_parent = \$context['_parent'];
|
\$_parent = \$context['_parent'];
|
||||||
unset(\$context['_seq'], \$context['k'], \$context['v'], \$context['_parent'], \$context['_iterated'], \$context['loop']);
|
unset(\$context['_seq'], \$context['k'], \$context['v'], \$context['_parent'], \$context['_iterated'], \$context['loop']);
|
||||||
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
\$context = array_intersect_key(\$context, \$_parent);
|
||||||
|
\$context += \$_parent;
|
||||||
EOF
|
EOF
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user