mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
Optimize the calculation of section 'total' property.
This commit is contained in:
@@ -714,9 +714,13 @@ class Smarty_Compiler extends Smarty {
|
|||||||
" {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
|
" {$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" .
|
$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 (!isset($attrs['start']) && !isset($attrs['step']) && !isset($attrs['max'])) {
|
||||||
" if ({$section_props}['total'] == 0)\n" .
|
$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" .
|
" {$section_props}['show'] = false;\n" .
|
||||||
"} else\n" .
|
"} else\n" .
|
||||||
" {$section_props}['total'] = 0;\n";
|
" {$section_props}['total'] = 0;\n";
|
||||||
|
@@ -714,9 +714,13 @@ class Smarty_Compiler extends Smarty {
|
|||||||
" {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
|
" {$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" .
|
$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 (!isset($attrs['start']) && !isset($attrs['step']) && !isset($attrs['max'])) {
|
||||||
" if ({$section_props}['total'] == 0)\n" .
|
$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" .
|
" {$section_props}['show'] = false;\n" .
|
||||||
"} else\n" .
|
"} else\n" .
|
||||||
" {$section_props}['total'] = 0;\n";
|
" {$section_props}['total'] = 0;\n";
|
||||||
|
Reference in New Issue
Block a user