mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
93e66ad14155941b327b2f2c6e9f57db99cfc7a1
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Optimize stripcslashes
See https://github.com/twigphp/Twig/pull/4176#issuecomment-2283168241 by `@smnandre`
```
# Old
Benchmark 1: php bench.php
Time (mean ± σ): 1.192 s ± 0.004 s [User: 1.163 s, System: 0.009 s]
Range (min … max): 1.186 s … 1.198 s 10 runs
# New
Benchmark 1: php bench.php
Time (mean ± σ): 356.5 ms ± 1.1 ms [User: 342.0 ms, System: 7.6 ms]
Range (min … max): 354.6 ms … 358.2 ms 10 runs
```
Using bench.php:
```php
<?php
require_once __DIR__.'/vendor/autoload.php';
$string = str_repeat("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut a tincidunt turpis. \\App\\Entity\\Product \World \065 App\#{var} \'quoted\' Donec pharetra enim quis erat pharetra, dignissim molestie erat laoreet. Vivamus auctor purus sed lorem vestibulum rhoncus.", 10);
$loader = new Twig\Loader\ArrayLoader([
'index.twig' => <<<EOF
{{ "$string" }}
EOF
,
]);
$twig = new Twig\Environment($loader);
for ($i = 0; $i < 10000; $i++) {
$twig->tokenize(new Twig\Source($twig->getLoader()->getSourceContext('index.twig')->getCode(), 'index.twig'));
}
```
Commits
-------
bc6e36de Optimize stripcslashes
…
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP.
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://docs.blackfire.io/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
<img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
</a>
More Information
----------------
Read the `documentation`_ for more information.
.. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%