mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-11 11:13:59 +02:00
- 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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user