cvs: smarty / NEWS /libs Smarty_Compiler.class.php

From: Date: Mon, 19 May 2003 22:38:29 +0000
Subject: cvs: smarty / NEWS /libs Smarty_Compiler.class.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-607@lists.php.net to get a copy of this message
mohrt Mon May 19 18:38:29 2003 EDT Modified files: /smarty NEWS /smarty/libs Smarty_Compiler.class.php Log: speed up compiled templates, hardcode plugin filepaths instead of recalculate at runtime Index: smarty/NEWS diff -u smarty/NEWS:1.362 smarty/NEWS:1.363 --- smarty/NEWS:1.362 Thu May 8 09:18:17 2003 +++ smarty/NEWS Mon May 19 18:38:28 2003 @@ -1,3 +1,5 @@ + - speed up compiled templates, hardcode plugin filepaths + instead of dynamically calculate at runtime. (Monte) - fixed bug in _create_dir_structure() when used with open_basedir- restriction and relative paths (messju) - use DIRECTORY_SEPARATOR exclusively, keep DIR_SEP for BC (Monte) Index: smarty/libs/Smarty_Compiler.class.php diff -u smarty/libs/Smarty_Compiler.class.php:1.229 smarty/libs/Smarty_Compiler.class.php:1.230 --- smarty/libs/Smarty_Compiler.class.php:1.229 Fri May 9 15:46:37 2003 +++ smarty/libs/Smarty_Compiler.class.php Mon May 19 18:38:28 2003 @@ -39,7 +39,7 @@ * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.229 2003/05/09 19:46:37 messju Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.230 2003/05/19 22:38:28 mohrt Exp $ */ /** * Template compiling class * @package Smarty @@ -339,20 +339,23 @@ /* Emit code to load needed plugins. */ if (count($this->_plugin_info)) { - $plugins_code = "<?php \$_params = array('plugins' => array("; + $_plugins_params = "array('plugins' => array("; foreach ($this->_plugin_info as $plugin_type => $plugins) { foreach ($plugins as $plugin_name => $plugin_info) { - $plugins_code .= "\narray('$plugin_type', '$plugin_name', '$plugin_info[0]', $plugin_info[1], "; - $plugins_code .= $plugin_info[2] ? 'true),' : 'false),'; + $_plugins_params .= "array('$plugin_type', '$plugin_name', '$plugin_info[0]', $plugin_info[1], "; + $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),'; } } - $plugins_code .= "));\n\$this->_execute_core_function('load_plugins', \$_params); ?>\n"; + $_plugins_params .= '))'; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'load_plugins'); + $plugins_code = "<?php require_once('$_plugin_filepath');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n"; $template_header .= $plugins_code; $this->_plugin_info = array(); } if ($this->_init_smarty_vars) { - $template_header .= "<?php \$this->_execute_core_function('assign_smarty_interface', \$params=null); ?>\n"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'assign_smarty_interface'); + $template_header .= "<?php require_once('$_plugin_filepath');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n"; $this->_init_smarty_vars = false; } @@ -765,7 +768,10 @@ $this->_add_plugin('insert', $name, $delayed_loading); - return "<?php \$_params = array('args' => array(".implode(', ', (array)$arg_list).")); echo \$this->_execute_core_function('run_insert_handler', \$_params); ?>\n"; + $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'run_insert_handler'); + + return "<?php require_once('$_plugin_filepath');\necho smarty_core_run_insert_handler($_params, \$this); ?>\n"; } /** @@ -803,9 +809,13 @@ } $output .= - "\$_smarty_tpl_vars = \$this->_tpl_vars;\n" . - "\$_params = array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."));\n" . - "\$this->_execute_core_function('smarty_include', \$_params);\n" . + "\$_smarty_tpl_vars = \$this->_tpl_vars;\n"; + + + $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include'); + + $output .= "require_once('$_plugin_filepath');\nsmarty_core_smarty_include($_params, \$this);\n" . "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . "unset(\$_smarty_tpl_vars);\n"; @@ -844,10 +854,10 @@ } } - $output = - "<?php \$_params = array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list).")); \$this->_execute_core_function('smarty_include_php', \$_params); ?>"; - - return $output; + $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; + $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include_php'); + + return "<?php require_once('$_plugin_filepath');\nsmarty_core_smarty_include_php($_params, \$this); ?>\n"; }

« previous php.smarty.cvs (#607) next »