simplified logic and improve perf slightly

This commit is contained in:
Fabien Potencier
2015-10-13 08:43:15 +02:00
parent 77c94ea205
commit 7030fdd767
2 changed files with 5 additions and 10 deletions
+1
View File
@@ -1,5 +1,6 @@
* 1.22.3 (2015-XX-XX)
* improved performance when checking template freshness
* changed template cache names to take into account the Twig C extension
* 1.22.2 (2015-09-22)
+4 -10
View File
@@ -455,15 +455,6 @@ class Twig_Environment
*/
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);
}
@@ -770,7 +761,10 @@ class Twig_Environment
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;
}