From 5f7b5a45ac6b3cc03f7d8964ff27eb58a41e7dc7 Mon Sep 17 00:00:00 2001 From: uwetews Date: Tue, 18 Aug 2015 02:57:10 +0200 Subject: [PATCH] improve performance --- libs/sysplugins/smarty_template_cached.php | 8 ++++---- libs/sysplugins/smarty_template_compiled.php | 18 ++++++++---------- libs/sysplugins/smarty_template_config.php | 9 ++++----- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/libs/sysplugins/smarty_template_cached.php b/libs/sysplugins/smarty_template_cached.php index f1bcfbed..7798cc7d 100644 --- a/libs/sysplugins/smarty_template_cached.php +++ b/libs/sysplugins/smarty_template_cached.php @@ -88,15 +88,15 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base */ static function load(Smarty_Internal_Template $_template) { - $_template->cached = $cached = new Smarty_Template_Cached($_template); - $cached->handler->populate($cached, $_template); + $_template->cached = new Smarty_Template_Cached($_template); + $_template->cached->handler->populate($_template->cached, $_template); // caching enabled ? if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled ) { - $cached->valid = false; + $_template->cached->valid = false; } - return $cached; + return $_template->cached; } /** diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index 29d6d408..afe307d4 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -36,28 +36,26 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base */ static function load($_template) { - $smarty = $_template->smarty; - $source = $_template->source; // check runtime cache - if (!$source->recompiled && ($smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON)) { - $_cache_key = $source->unique_resource . '#'; + if (!$_template->source->recompiled && ($_template->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON)) { + $_cache_key = $_template->source->unique_resource . '#'; if ($_template->caching) { $_cache_key .= 'caching#'; } $_cache_key .= $_template->compile_id; - if (isset($source->compileds[$_cache_key])) { - return $source->compileds[$_cache_key]; + if (isset($_template->source->compileds[$_cache_key])) { + return $_template->source->compileds[$_cache_key]; } } $compiled = new Smarty_Template_Compiled(); - if (method_exists($source->handler, 'populateCompiledFilepath')) { - $source->handler->populateCompiledFilepath($compiled, $_template); + if (method_exists($_template->source->handler, 'populateCompiledFilepath')) { + $_template->source->handler->populateCompiledFilepath($compiled, $_template); } else { $compiled->populateCompiledFilepath($_template); } // runtime cache - if (!$source->recompiled && ($smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON)) { - $source->compileds[$_cache_key] = $compiled; + if (!$_template->source->recompiled && ($_template->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON)) { + $_template->source->compileds[$_cache_key] = $compiled; } return $compiled; } diff --git a/libs/sysplugins/smarty_template_config.php b/libs/sysplugins/smarty_template_config.php index 57739de8..73ef7c18 100644 --- a/libs/sysplugins/smarty_template_config.php +++ b/libs/sysplugins/smarty_template_config.php @@ -92,24 +92,23 @@ class Smarty_Template_Config extends Smarty_Template_Source public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null) { static $_incompatible_resources = array('extends' => true, 'php' => true); - $smarty = $_template->smarty; $template_resource = $_template->template_resource; if (empty($template_resource)) { throw new SmartyException('Missing config name'); } // parse resource_name, load resource handler - list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type); + list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $_template->smarty->default_config_type); // make sure configs are not loaded via anything smarty can't handle if (isset($_incompatible_resources[$type])) { throw new SmartyException ("Unable to use resource '{$type}' for config"); } - $resource = Smarty_Resource::load($smarty, $type); - $source = new Smarty_Template_Config($resource, $smarty, $template_resource, $type, $name); + $resource = Smarty_Resource::load($_template->smarty, $type); + $source = new Smarty_Template_Config($resource, $_template->smarty, $template_resource, $type, $name); $resource->populate($source, $_template); if (!$source->exists && isset($_template->smarty->default_config_handler_func)) { Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); } - $source->unique_resource = $resource->buildUniqueResourceName($smarty, $name, true); + $source->unique_resource = $resource->buildUniqueResourceName($_template->smarty, $name, true); return $source; } }