From: Fabien Potencier Date: Fri, 29 Apr 2011 13:23:00 +0000 (+0200) Subject: made a small speed optimization when using auto-escaping X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=109ce302888b0232ede4262abe016f6022704c85;p=web%2Fkonrad%2Ftwig.git made a small speed optimization when using auto-escaping --- diff --git a/lib/Twig/NodeVisitor/SafeAnalysis.php b/lib/Twig/NodeVisitor/SafeAnalysis.php index 5b1bdb2..1874581 100644 --- a/lib/Twig/NodeVisitor/SafeAnalysis.php +++ b/lib/Twig/NodeVisitor/SafeAnalysis.php @@ -44,6 +44,12 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface if ($node instanceof Twig_Node_Expression_Constant) { // constants are marked safe for all $this->setSafe($node, array('all')); + } elseif ($node instanceof Twig_Node_Expression_BlockReference) { + // blocks are safe by definition + $this->setSafe($node, array('all')); + } elseif ($node instanceof Twig_Node_Expression_Parent) { + // parent block is safe by definition + $this->setSafe($node, array('all')); } elseif ($node instanceof Twig_Node_Expression_Conditional) { // intersect safeness of both operands $safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3'))); diff --git a/lib/Twig/Template.php b/lib/Twig/Template.php index 4484293..5a987d7 100644 --- a/lib/Twig/Template.php +++ b/lib/Twig/Template.php @@ -114,7 +114,7 @@ abstract class Twig_Template implements Twig_TemplateInterface ob_start(); $this->displayParentBlock($name, $context, $blocks); - return new Twig_Markup(ob_get_clean()); + return ob_get_clean(); } /** @@ -131,7 +131,7 @@ abstract class Twig_Template implements Twig_TemplateInterface ob_start(); $this->displayBlock($name, $context, $blocks); - return new Twig_Markup(ob_get_clean()); + return ob_get_clean(); } /**