Skip to content

Commit

Permalink
Don't use function in for loop test.
Browse files Browse the repository at this point in the history
Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
  • Loading branch information
Tithugues committed Dec 18, 2013
1 parent 8381c6e commit 493f9c5
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions libraries/TableSearch.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ private function _getOptionsZoom($dataLabel)
. __("Use this column to label each point") . '</label></td>';
$html_output .= '<td><select name="dataLabel" id="dataLabel" >'
. '<option value = "">' . __('None') . '</option>';
for ($j = 0; $j < count($this->_columnNames); $j++) {
for ($j = 0, $nb = count($this->_columnNames); $j < $nb; $j++) {
if (isset($dataLabel)
&& $dataLabel == htmlspecialchars($this->_columnNames[$j])
) {
Expand Down Expand Up @@ -970,8 +970,8 @@ private function _getRowsNormal()
$html_output = '';
// for every column present in table
for (
$column_index = 0;
$column_index < count($this->_columnNames);
$column_index = 0, $nb = count($this->_columnNames);
$column_index < $nb;
$column_index++
) {
$html_output .= '<tr class="noclick '
Expand Down
2 changes: 1 addition & 1 deletion libraries/dbi/DBIDummy.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public function selectDb($dbname, $link = null)
public function realQuery($query, $link = null, $options = 0)
{
$query = trim(preg_replace('/ */', ' ', str_replace("\n", ' ', $query)));
for ($i = 0; $i < count($GLOBALS['dummy_queries']); $i++) {
for ($i = 0, $nb = count($GLOBALS['dummy_queries']); $i < $nb; $i++) {
if ($GLOBALS['dummy_queries'][$i]['query'] != $query) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/gis/pma_gis_polygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public static function isPointInsidePolygon($point, $polygon)
public static function getPointOnSurface($ring)
{
// Find two consecutive distinct points.
for ($i = 0; $i < count($ring) - 1; $i++) {
for ($i = 0, $nb = count($ring) - 1; $i < $nb; $i++) {
if ($ring[$i]['y'] != $ring[$i + 1]['y']) {
$x0 = $ring[$i]['x'];
$x1 = $ring[$i + 1]['x'];
Expand Down
2 changes: 1 addition & 1 deletion libraries/insert_edit.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ function PMA_getAfterInsertDropDown($where_clause, $after_insert, $found_unique_
if (! is_array($where_clause)) {
$where_clause = array($where_clause);
}
for ($i = 0; $i < count($where_clause); $i++) {
for ($i = 0, $nb = count($where_clause); $i < $nb; $i++) {
$is_numeric = preg_match(
'@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@',
$where_clause[$i]
Expand Down
2 changes: 1 addition & 1 deletion libraries/rte/rte_routines.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ function PMA_RTN_getQueryFromRequest()
$item_param_type = $_REQUEST['item_param_type'];
$item_param_length = $_REQUEST['item_param_length'];

for ($i=0; $i < count($item_param_name); $i++) {
for ($i=0, $nb = count($item_param_name); $i < $nb; $i++) {
if (! empty($item_param_name[$i])
&& ! empty($item_param_type[$i])
) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/server_plugins.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function PMA_getModuleList($modules)
$html .= '<td><b class="plugin-type">'
. htmlspecialchars($plugin_type) . '</b></td>';
$html .= '<td>';
for ($i = 0; $i < count($plugin_list); $i++) {
for ($i = 0, $nb = count($plugin_list); $i < $nb; $i++) {
$html .= ($i != 0 ? '<br />' : '')
. htmlspecialchars($plugin_list[$i]['plugin_name']);
if (!$plugin_list[$i]['is_active']) {
Expand Down
2 changes: 1 addition & 1 deletion setup/lib/ConfigGenerator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static function _getVarExport($var_name, $var_value, $crlf)
*/
private static function _isZeroBasedArray(array $array)
{
for ($i = 0; $i < count($array); $i++) {
for ($i = 0, $nb = count($array); $i < $nb; $i++) {
if (! isset($array[$i])) {
return false;
}
Expand Down

2 comments on commit 493f9c5

@lem9
Copy link
Contributor

@lem9 lem9 commented on 493f9c5 Dec 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvements!

@Tithugues
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
Those modifications shouldn't change the result of scripts, but only improve the performances. (Well... The script won't take one second less... This will be micro-seconds less.)

This is one of the PHPCS rule I'd like to add.

Please sign in to comment.