mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-28 19:01:37 +01:00
optimized for loops with count() function calls
This commit is contained in:
@@ -37,7 +37,7 @@ function smarty_function_html_select_time($params, &$smarty)
|
||||
if ($display_hours) {
|
||||
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
|
||||
$hour_fmt = $use_24_hours ? '%H' : '%I';
|
||||
for ($i = 0; $i < count($hours); $i++)
|
||||
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
|
||||
$hours[$i] = sprintf('%02d', $hours[$i]);
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
@@ -55,7 +55,7 @@ function smarty_function_html_select_time($params, &$smarty)
|
||||
|
||||
if ($display_minutes) {
|
||||
$all_minutes = range(0, 59);
|
||||
for ($i = 0; $i < count($all_minutes); $i+= $minute_interval)
|
||||
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
|
||||
$minutes[] = sprintf('%02d', $all_minutes[$i]);
|
||||
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
|
||||
$html_result .= '<select name=';
|
||||
@@ -74,7 +74,7 @@ function smarty_function_html_select_time($params, &$smarty)
|
||||
|
||||
if ($display_seconds) {
|
||||
$all_seconds = range(0, 59);
|
||||
for ($i = 0; $i < count($all_seconds); $i+= $second_interval)
|
||||
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
|
||||
$seconds[] = sprintf('%02d', $all_seconds[$i]);
|
||||
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
|
||||
$html_result .= '<select name=';
|
||||
|
||||
Reference in New Issue
Block a user