slight optimization in the compilation of $smarty.const.FOO .

@FOO is less code and executed slightly faster than constant('FOO').

more complex consts like $smarty.const.$name still compile to
constant($this->_tpl_vars['name'])
This commit is contained in:
messju
2005-01-06 17:17:05 +00:00
parent b891cba32f
commit 6e323a8df2
2 changed files with 9 additions and 2 deletions

3
NEWS
View File

@@ -1,3 +1,6 @@
- make $smarty.const.FOO compile to "FOO", and not to "constant('foo')".
this is less code and a little faster execution. note that undefined
constants are now displayed as the constant's name. (messju)
- make block functions and registered objects' block methods use a
local variable for block_content instead of a property of $smarty (messju)
- fix escaping in the generated code that calls smarty_core_load_plugins

View File

@@ -2031,8 +2031,12 @@ class Smarty_Compiler extends Smarty {
return;
}
array_shift($indexes);
$_val = $this->_parse_var_props(substr($indexes[0],1));
$compiled_ref = '@constant(' . $_val . ')';
if (preg_match('!^\.\w+$!', $indexes[0])) {
$compiled_ref = '@' . substr($indexes[0], 1);
} else {
$_val = $this->_parse_var_props(substr($indexes[0], 1));
$compiled_ref = '@constant(' . $_val . ')';
}
$_max_index = 1;
break;