From 9f3758ace1a46b92b48912f5b5ba11676db59254 Mon Sep 17 00:00:00 2001 From: "uwe.tews@googlemail.com" Date: Wed, 22 Dec 2010 16:35:39 +0000 Subject: [PATCH] do not clone Smarty object on internal createTemplate() calls --- change_log.txt | 3 +++ libs/Smarty.class.php | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/change_log.txt b/change_log.txt index 79268ce8..3863c856 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,8 @@ ===== SVN trunk ===== +22/12/2010 +- update do not clone the Smarty object an internal createTemplate() calls to increase performance + 21/12/2010 - update html_options to support class and id attrs diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index f9f50679..e3e5aba5 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -317,7 +317,7 @@ class Smarty extends Smarty_Internal_Data { } // create template object if necessary ($template instanceof $this->template_class)? $_template = $template : - $_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent); + $_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false); if (isset($this->error_reporting)) { $_smarty_old_error_level = error_reporting($this->error_reporting); } @@ -396,7 +396,7 @@ class Smarty extends Smarty_Internal_Data { $parent = $this; } if (!($template instanceof $this->template_class)) { - $template = $this->createTemplate ($template, $cache_id, $compile_id, $parent); + $template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false); } // return cache status of template return $template->isCached(); @@ -417,12 +417,13 @@ class Smarty extends Smarty_Internal_Data { * creates a template object * * @param string $template the resource handle of the template file - * @param object $parent next higher level of Smarty variables * @param mixed $cache_id cache id to be used with this template * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * @param boolean $do_clone flag is Smarty object shall be cloned * @returns object template object */ - public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null) + public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true) { if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) { $parent = $cache_id; @@ -443,7 +444,11 @@ class Smarty extends Smarty_Internal_Data { $tpl = $this->template_objects[$_templateId]; } else { // create new template object - $tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id); + if ($do_clone) { + $tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id); + } else { + $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); + } } } else { // just return a copy of template class