From: Jordi Boggiano Date: Mon, 6 May 2013 12:12:55 +0000 (+0200) Subject: Avoid strtolower call at every twig_escape_filter call X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=c891c530d36c797cebeb91d2e69af5ebfe0c8a82;p=web%2Fkonrad%2Ftwig.git Avoid strtolower call at every twig_escape_filter call --- diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index e0a6a33..8d984eb 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -885,7 +885,14 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', 'iso8859-5' => true, 'iso-8859-5' => true, 'macroman' => true, ); + if (isset($htmlspecialcharsCharsets[$charset])) { + return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset); + } + if (isset($htmlspecialcharsCharsets[strtolower($charset)])) { + // cache the uppercase variant for future iterations + $htmlspecialcharsCharsets[$charset] = true; + return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset); }