Take out one more stat call (on the compiled template) by not calculating it's existence / timestamp when compile_check is false.

This commit is contained in:
Simon Wisselink
2021-03-12 23:10:33 +01:00
parent a832410ef3
commit 1eb2851c03

View File

@@ -74,9 +74,14 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
$this->filepath .= '.cache'; $this->filepath .= '.cache';
} }
$this->filepath .= '.php'; $this->filepath .= '.php';
$this->timestamp = $this->exists = is_file($this->filepath);
if ($this->exists) { if ($smarty->compile_check) {
$this->timestamp = filemtime($this->filepath); $this->timestamp = $this->exists = is_file($this->filepath);
if ($this->exists) {
$this->timestamp = filemtime($this->filepath);
}
} else {
$this->timestamp = $this->exists = true;
} }
} }
@@ -135,8 +140,9 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
if ($source->handler->recompiled) { if ($source->handler->recompiled) {
$source->handler->process($_smarty_tpl); $source->handler->process($_smarty_tpl);
} elseif (!$source->handler->uncompiled) { } elseif (!$source->handler->uncompiled) {
if (!$this->exists || $smarty->force_compile if (
|| ($_smarty_tpl->compile_check && $source->getTimeStamp() > $this->getTimeStamp()) $smarty->force_compile ||
($_smarty_tpl->compile_check && (!$this->exists || ($source->getTimeStamp() > $this->getTimeStamp())))
) { ) {
$this->compileTemplateSource($_smarty_tpl); $this->compileTemplateSource($_smarty_tpl);
$compileCheck = $_smarty_tpl->compile_check; $compileCheck = $_smarty_tpl->compile_check;