mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
0f45c2a67702e1b38f79c8485453e67731059783
This PR was merged into the 1.x branch.
Discussion
----------
Use isset before array_key_exists
Small performance improvment when using
```
{% set foo = foo|default("bar") %}
```
Will render the following code
```
$context["foo"] = (((isset($context["foo"]) || array_key_exists("foo", $context))) ? (_twig_default_filter((isset($context["foo"]) || array_key_exists("foo", $context) ? $context["foo"] : (function () { throw new Twig_Error_Runtime('Variable "foo" does not exist.', 1, $this->source); })()), "bar")) : ("bar"));
```
instead of
```
$context["foo"] = ((array_key_exists("foo", $context)) ? (_twig_default_filter((isset($context["foo"]) || array_key_exists("foo", $context) ? $context["foo"] : (function () { throw new Twig_Error_Runtime('Variable "foo" does not exist.', 1, $this->source); })()), "bar")) : ("bar"));
```
Commits
-------
230d3412 Use isset before array_key_exists
…
Twig, the flexible, fast, and secure template language for PHP ============================================================== Twig is a template language for PHP, released under the new BSD license (code and documentation). Twig uses a syntax similar to the Django and Jinja template languages which inspired the Twig runtime environment. More Information ---------------- Read the `documentation`_ for more information. .. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%