mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 04:16:28 +00:00
fixed performance when compiling large files
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 1.6.4 (2012-XX-XX)
|
||||
|
||||
* fixed performance when compiling large files
|
||||
* optimized parent template creation when the template does not use dynamic inheritance
|
||||
|
||||
* 1.6.3 (2012-03-22)
|
||||
|
||||
@@ -23,6 +23,8 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
protected $indentation;
|
||||
protected $env;
|
||||
protected $debugInfo;
|
||||
protected $sourceOffset;
|
||||
protected $sourceLine;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -67,6 +69,8 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
{
|
||||
$this->lastLine = null;
|
||||
$this->source = '';
|
||||
$this->sourceOffset = 0;
|
||||
$this->sourceLine = 0;
|
||||
$this->indentation = $indentation;
|
||||
|
||||
$node->compile($this);
|
||||
@@ -188,7 +192,9 @@ class Twig_Compiler implements Twig_CompilerInterface
|
||||
public function addDebugInfo(Twig_NodeInterface $node)
|
||||
{
|
||||
if ($node->getLine() != $this->lastLine) {
|
||||
$this->debugInfo[substr_count($this->source, "\n")] = $node->getLine();
|
||||
$this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
|
||||
$this->sourceOffset = strlen($this->source);
|
||||
$this->debugInfo[$this->sourceLine] = $node->getLine();
|
||||
|
||||
$this->lastLine = $node->getLine();
|
||||
$this->write("// line {$node->getLine()}\n");
|
||||
|
||||
Reference in New Issue
Block a user