- performance store flag for already required shared plugin functions in static variable or

Smarty's $_cache to improve performance when plugins are often called
    https://github.com/smarty-php/smarty/commit/51e0d5cd405d764a4ea257d1bac1fb1205f74528#commitcomment-22280086
This commit is contained in:
uwetews
2017-05-27 11:04:00 +02:00
parent a49a08748f
commit e51b0ac4af
13 changed files with 126 additions and 45 deletions
+6 -3
View File
@@ -38,8 +38,9 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
if (is_null($content)) {
return;
}
if (Smarty::$_MBSTRING && !is_callable('smarty_mb_wordwrap')) {
if (!isset($template->smarty->_cache[ '_required_smw' ])) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
$template->smarty->_cache[ '_required_smw' ] = true;
}
$style = null;
@@ -87,8 +88,10 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
}
// convert mult. spaces & special chars to single space
$_paragraph =
preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
array(' ', ''), $_paragraph);
preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER,
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
array(' ',
''), $_paragraph);
// indent first line
if ($indent_first > 0) {
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;