- improvement removed some unnecessary count()s

This commit is contained in:
rodneyrehm
2011-10-07 14:05:26 +00:00
parent 1f35133079
commit b7ef6f0597
4 changed files with 16 additions and 15 deletions

View File

@@ -5,6 +5,7 @@
- improvement testInstall() now showing resolved paths and checking the include_path if necessary
- bugfix html_options plugin did not handle object values properly (Issue #49, Forum Topic 20049)
- improvement html_checkboxes and html_radios to accept null- and object values, and label_ids attribute
- improvement removed some unnecessary count()s
06.10.2011
- bugfix switch lexer internals depending on mbstring.func_overload

View File

@@ -78,26 +78,27 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
$_paragraphs = preg_split('![\r\n]{2}!', $content);
$_output = '';
for ($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
if ($_paragraphs[$_x] == '') {
foreach ($_paragraphs as &$_paragraph) {
if (!$_paragraph) {
continue;
}
// convert mult. spaces & special chars to single space
$_paragraphs[$_x] = preg_replace(array('!\s+!u', '!(^\s+)|(\s+$)!u'), array(' ', ''), $_paragraphs[$_x]);
$_paragraph = preg_replace(array('!\s+!u', '!(^\s+)|(\s+$)!u'), array(' ', ''), $_paragraph);
// indent first line
if ($indent_first > 0) {
$_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
}
// wordwrap sentences
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
$_paragraphs[$_x] = smarty_mb_wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
$_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
} else {
$_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
$_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
}
// indent lines
if ($indent > 0) {
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
$_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph);
}
}
$_output = implode($wrap_char . $wrap_char, $_paragraphs);

View File

@@ -88,12 +88,9 @@ function smarty_function_mailto($params, $template)
}
}
$mail_parm_vals = '';
for ($i = 0, $_length = count($mail_parms); $i < $_length; $i++) {
$mail_parm_vals .= (0 == $i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i];
if ($mail_parms) {
$address .= '?' . join('&', $mail_parms);
}
$address .= $mail_parm_vals;
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
if (!isset($_allowed_encoding[$encode])) {

View File

@@ -24,8 +24,10 @@ function smarty_modifiercompiler_default ($params, $compiler)
if (!isset($params[1])) {
$params[1] = "''";
}
for ($i = 1, $cnt = count($params); $i < $cnt; $i++) {
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $params[$i] . ' : $tmp)';
array_shift($params);
foreach ($params as $param) {
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
}
return $output;
}