optimized for loops with count() function calls

This commit is contained in:
mohrt
2002-06-03 16:05:33 +00:00
parent f1d75e32c8
commit 51a14712f8
11 changed files with 40 additions and 29 deletions

View File

@@ -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=';