mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
Make happy path (strings) faster by avoiding the cast, same perfs for the other cases
This commit is contained in:
@@ -851,16 +851,18 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
||||
return $string;
|
||||
}
|
||||
|
||||
if (!is_string($string) && !(is_object($string) && method_exists($string, '__toString'))) {
|
||||
return $string;
|
||||
if (!is_string($string)) {
|
||||
if (is_object($string) && method_exists($string, '__toString')) {
|
||||
$string = (string) $string;
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $charset) {
|
||||
$charset = $env->getCharset();
|
||||
}
|
||||
|
||||
$string = (string) $string;
|
||||
|
||||
switch ($strategy) {
|
||||
case 'html':
|
||||
// see http://php.net/htmlspecialchars
|
||||
|
||||
Reference in New Issue
Block a user