made a small speed optimization when using auto-escaping
authorFabien Potencier <fabien.potencier@gmail.com>
Fri, 29 Apr 2011 13:23:00 +0000 (15:23 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Fri, 29 Apr 2011 13:23:00 +0000 (15:23 +0200)
lib/Twig/NodeVisitor/SafeAnalysis.php
lib/Twig/Template.php

index 5b1bdb2..1874581 100644 (file)
@@ -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')));
index 4484293..5a987d7 100644 (file)
@@ -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();
     }
 
     /**