From 1eb2851c036052a9b84de668e0f234f47f281c82 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Fri, 12 Mar 2021 23:10:33 +0100 Subject: [PATCH] Take out one more stat call (on the compiled template) by not calculating it's existence / timestamp when compile_check is false. --- libs/sysplugins/smarty_template_compiled.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index 37d8f0a9..85e9065e 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -74,9 +74,14 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base $this->filepath .= '.cache'; } $this->filepath .= '.php'; - $this->timestamp = $this->exists = is_file($this->filepath); - if ($this->exists) { - $this->timestamp = filemtime($this->filepath); + + if ($smarty->compile_check) { + $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) { $source->handler->process($_smarty_tpl); } elseif (!$source->handler->uncompiled) { - if (!$this->exists || $smarty->force_compile - || ($_smarty_tpl->compile_check && $source->getTimeStamp() > $this->getTimeStamp()) + if ( + $smarty->force_compile || + ($_smarty_tpl->compile_check && (!$this->exists || ($source->getTimeStamp() > $this->getTimeStamp()))) ) { $this->compileTemplateSource($_smarty_tpl); $compileCheck = $_smarty_tpl->compile_check;