projects
/
web/konrad/twig.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
97bf5e5
)
Make happy path (strings) faster by avoiding the cast, same perfs for the other cases
author
Jordi Boggiano
<j.boggiano@seld.be>
Mon, 6 May 2013 12:32:20 +0000 (14:32 +0200)
committer
Jordi Boggiano
<j.boggiano@seld.be>
Mon, 6 May 2013 12:32:20 +0000 (14:32 +0200)
lib/Twig/Extension/Core.php
patch
|
blob
|
history
diff --git
a/lib/Twig/Extension/Core.php
b/lib/Twig/Extension/Core.php
index
657c3d8
..
c3ca51a
100644
(file)
--- a/
lib/Twig/Extension/Core.php
+++ b/
lib/Twig/Extension/Core.php
@@
-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