cvs: smarty / Smarty_Compiler.class.php
| From: | Andrei Zmievski | Date: | Thu, 13 Jun 2002 20:14:46 +0000 |
| Subject: | cvs: smarty / Smarty_Compiler.class.php | ||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-134@lists.php.net to get a copy of this message | ||
andrei Thu Jun 13 16:14:46 2002 EDT
Modified files:
/smarty Smarty_Compiler.class.php
Log:
Optimize the calculation of section 'total' property.
Index: smarty/Smarty_Compiler.class.php
diff -u smarty/Smarty_Compiler.class.php:1.116 smarty/Smarty_Compiler.class.php:1.117
--- smarty/Smarty_Compiler.class.php:1.116 Mon Jun 3 12:05:32 2002
+++ smarty/Smarty_Compiler.class.php Thu Jun 13 16:14:46 2002
@@ -714,9 +714,13 @@
" {$section_props}['start'] =
min({$section_props}['start'], {$section_props}['step'] > 0 ?
{$section_props}['loop'] : {$section_props}['loop']-1);\n";
}
- $output .= "if ({$section_props}['show']) {\n" .
- " {$section_props}['total'] =
min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] -
{$section_props}['start'] :
{$section_props}['start']+1)/abs({$section_props}['step'])),
{$section_props}['max']);\n" .
- " if ({$section_props}['total'] == 0)\n" .
+ $output .= "if ({$section_props}['show']) {\n";
+ if (!isset($attrs['start']) && !isset($attrs['step'])
&& !isset($attrs['max'])) {
+ $output .= " {$section_props}['total'] =
{$section_props}['loop'];\n";
+ } else {
+ $output .= " {$section_props}['total'] =
min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] -
{$section_props}['start'] :
{$section_props}['start']+1)/abs({$section_props}['step'])),
{$section_props}['max']);\n";
+ }
+ $output .= " if ({$section_props}['total'] == 0)\n" .
" {$section_props}['show'] = false;\n" .
"} else\n" .
" {$section_props}['total'] = 0;\n";