mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- minor optimizations
This commit is contained in:
@@ -97,7 +97,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
*/
|
*/
|
||||||
$_smarty_tpl = $_template;
|
$_smarty_tpl = $_template;
|
||||||
$_template->cached->valid = false;
|
$_template->cached->valid = false;
|
||||||
if ($update && strpos(phpversion(), 'hhvm') !== false) {
|
if ($update && defined('HHVM_VERSION')) {
|
||||||
return $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->cached->filepath);
|
return $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->cached->filepath);
|
||||||
} else {
|
} else {
|
||||||
return @include $_template->cached->filepath;
|
return @include $_template->cached->filepath;
|
||||||
|
@@ -151,7 +151,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||||
$output .= "foreach (Smarty::\\\$global_tpl_vars as \\\$key => \\\$value){\n";
|
$output .= "foreach (Smarty::\\\$global_tpl_vars as \\\$key => \\\$value){\n";
|
||||||
$output .= "if (\\\$_smarty_tpl->tpl_vars[\\\$key] === \\\$value) \\\$saved_tpl_vars[\\\$key] = \\\$value;\n}\n";
|
$output .= "if (!isset(\\\$_smarty_tpl->tpl_vars[\\\$key]) || \\\$_smarty_tpl->tpl_vars[\\\$key] === \\\$value) \\\$saved_tpl_vars[\\\$key] = \\\$value;\n}\n";
|
||||||
$output .= "\\\$_smarty_tpl->tpl_vars = \\\$saved_tpl_vars;?>\n";
|
$output .= "\\\$_smarty_tpl->tpl_vars = \\\$saved_tpl_vars;?>\n";
|
||||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
|
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
|
||||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
|
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
|
||||||
@@ -173,7 +173,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||||
$output = "<?php foreach (Smarty::\$global_tpl_vars as \$key => \$value){\n";
|
$output = "<?php foreach (Smarty::\$global_tpl_vars as \$key => \$value){\n";
|
||||||
$output .= "if (\$_smarty_tpl->tpl_vars[\$key] === \$value) \$saved_tpl_vars[\$key] = \$value;\n}\n";
|
$output .= "if (!isset(\$_smarty_tpl->tpl_vars[\$key]) || \$_smarty_tpl->tpl_vars[\$key] === \$value) \$saved_tpl_vars[\$key] = \$value;\n}\n";
|
||||||
$output .= "\$_smarty_tpl->tpl_vars = \$saved_tpl_vars;\n}\n}\n";
|
$output .= "\$_smarty_tpl->tpl_vars = \$saved_tpl_vars;\n}\n}\n";
|
||||||
$output .= "/*/ {$_funcName} */\n\n";
|
$output .= "/*/ {$_funcName} */\n\n";
|
||||||
$output .= "?>\n";
|
$output .= "?>\n";
|
||||||
|
@@ -169,7 +169,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
|||||||
opcache_invalidate($_template->compiled->filepath);
|
opcache_invalidate($_template->compiled->filepath);
|
||||||
}
|
}
|
||||||
$_smarty_tpl = $_template;
|
$_smarty_tpl = $_template;
|
||||||
if (strpos(phpversion(), 'hhvm') !== false) {
|
if (defined('HHVM_VERSION')) {
|
||||||
$_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->compiled->filepath);
|
$_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->compiled->filepath);
|
||||||
} else {
|
} else {
|
||||||
include($_template->compiled->filepath);
|
include($_template->compiled->filepath);
|
||||||
|
@@ -157,9 +157,9 @@ class Smarty_Template_Source
|
|||||||
throw new SmartyException('Missing template name');
|
throw new SmartyException('Missing template name');
|
||||||
}
|
}
|
||||||
// parse resource_name, load resource handler, identify unique resource name
|
// parse resource_name, load resource handler, identify unique resource name
|
||||||
if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $template_resource, $match)) {
|
if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) {
|
||||||
$type = $match[1];
|
$type = $match[1];
|
||||||
$name = substr($template_resource, strlen($match[0]));
|
$name = $match[2];
|
||||||
} else {
|
} else {
|
||||||
// no resource given, use default
|
// no resource given, use default
|
||||||
// or single character before the colon is not a resource type, but part of the filepath
|
// or single character before the colon is not a resource type, but part of the filepath
|
||||||
|
Reference in New Issue
Block a user