You are here

protected function Twig_NodeVisitor_Optimizer::leaveOptimizeFor in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php \Twig_NodeVisitor_Optimizer::leaveOptimizeFor()

Optimizes "for" tag by removing the "loop" variable creation whenever possible.

Parameters

Twig_NodeInterface $node A Node:

Twig_Environment $env The current Twig environment:

1 call to Twig_NodeVisitor_Optimizer::leaveOptimizeFor()
Twig_NodeVisitor_Optimizer::doLeaveNode in vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php
Called after child nodes are visited.

File

vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php, line 243

Class

Twig_NodeVisitor_Optimizer
Twig_NodeVisitor_Optimizer tries to optimizes the AST.

Code

protected function leaveOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env) {
  if ($node instanceof Twig_Node_For) {
    array_shift($this->loops);
    array_shift($this->loopsTargets);
    array_shift($this->loopsTargets);
  }
}