From 0d502f3b07df4c198688d87a08bd6f785db77a1d Mon Sep 17 00:00:00 2001 From: David M Date: Sat, 23 Dec 2006 18:27:15 +0000 Subject: - quite a few optimizations to the template engine. bitwise arithmatic is used to check odd/even, usage of ref to the root template variables should reduce the number of hash lookups needed, usage of refs within loops should reduce the amount of hash lookups, incrementing vars were turned from class variables to regular variables, cache now uses preincrementing variables instead of postincrementing variables, some regex were optimized/trimmed - a bug fix somewhere in there... git-svn-id: file:///svn/phpbb/trunk@6796 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/template.php') diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 76a89869f5..97c92558b6 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -23,11 +23,12 @@ class template { /** variable that holds all the data we'll be substituting into * the compiled templates. Takes form: - * --> $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value + * --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value * if it's a root-level variable, it'll be like this: * --> $this->_tpldata[.][0][varname] == value */ - var $_tpldata = array(); + var $_tpldata = array('.' => array(0 => array())); + var $_rootref; // Root dir and hash of filenames for each template handle. var $root = ''; @@ -55,6 +56,8 @@ class template trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR); } + $this->_rootref = &$this->_tpldata['.'][0]; + return true; } @@ -104,7 +107,7 @@ class template */ function destroy() { - $this->_tpldata = array(); + $this->_tpldata = array('.' => array(0 => array())); } /** @@ -205,7 +208,7 @@ class template $compile = new template_compile($this); // If the file for this handle is already loaded and compiled, do nothing. - if (!empty($this->uncompiled_code[$handle])) + if (!empty($this->compiled_code[$handle])) { return true; } @@ -281,7 +284,7 @@ class template { foreach ($vararray as $key => $val) { - $this->_tpldata['.'][0][$key] = $val; + $this->_rootref[$key] = $val; } return true; @@ -293,7 +296,7 @@ class template */ function assign_var($varname, $varval) { - $this->_tpldata['.'][0][$varname] = $varval; + $this->_rootref[$varname] = $varval; return true; } -- cgit v1.2.1