mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 13:26:37 +00:00
simplified logic and improve perf slightly
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
* 1.22.3 (2015-XX-XX)
|
* 1.22.3 (2015-XX-XX)
|
||||||
|
|
||||||
|
* improved performance when checking template freshness
|
||||||
* changed template cache names to take into account the Twig C extension
|
* changed template cache names to take into account the Twig C extension
|
||||||
|
|
||||||
* 1.22.2 (2015-09-22)
|
* 1.22.2 (2015-09-22)
|
||||||
|
|||||||
@@ -455,15 +455,6 @@ class Twig_Environment
|
|||||||
*/
|
*/
|
||||||
public function isTemplateFresh($name, $time)
|
public function isTemplateFresh($name, $time)
|
||||||
{
|
{
|
||||||
if(0 === $this->lastModifiedExtension) {
|
|
||||||
foreach ($this->extensions as $extension) {
|
|
||||||
$r = new ReflectionObject($extension);
|
|
||||||
if (($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
|
|
||||||
$this->lastModifiedExtension = $extensionTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->lastModifiedExtension <= $time && $this->getLoader()->isFresh($name, $time);
|
return $this->lastModifiedExtension <= $time && $this->getLoader()->isFresh($name, $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,7 +761,10 @@ class Twig_Environment
|
|||||||
throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
|
throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lastModifiedExtension = 0;
|
$r = new ReflectionObject($extension);
|
||||||
|
if (($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
|
||||||
|
$this->lastModifiedExtension = $extensionTime;
|
||||||
|
}
|
||||||
|
|
||||||
$this->extensions[$extension->getName()] = $extension;
|
$this->extensions[$extension->getName()] = $extension;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user