From f0eb21fba8dd7197095551d5643959d6db7e73fa Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Sat, 4 Apr 2009 12:41:02 +0000 Subject: [PATCH] patch #2727250 Optimizations for some PHP loops --- ChangeLog | 2 ++ libraries/common.lib.php | 9 +++++---- pmd_common.php | 6 +++--- pmd_general.php | 7 ++++--- setup/lib/index.lib.php | 2 +- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3d893e4b..83cb86140 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,8 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA thanks to Pawel Smolinski - zipoking + patch #2715142 [export] (rfe 2416960, escape new line in CSV export) thanks to Derek Schaefer - drummingds1 +- patch #2727250 Optimizations for PHP loops + thanks to Haeber 3.1.4.0 (not yet released) + patch #1808339 [doc] Apache SSLOptions and StdEnvVars FAQ, diff --git a/libraries/common.lib.php b/libraries/common.lib.php index c0f008209..cec884a1b 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -813,7 +813,8 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count = $group =& $table_groups; $i = 0; $group_name_full = ''; - while ($i < count($parts) - 1 + $parts_cnt = count($parts) - 1; + while ($i < $parts_cnt && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) { $group_name = $parts[$i] . $sep; $group_name_full .= $group_name; @@ -1798,7 +1799,7 @@ function PMA_flipstring($string, $Separator = "
\n") $format_string = ''; $charbuff = false; - for ($i = 0; $i < strlen($string); $i++) { + for ($i = 0, $str_len = strlen($string); $i < $str_len; $i++) { $char = $string{$i}; $append = false; @@ -1817,7 +1818,7 @@ function PMA_flipstring($string, $Separator = "
\n") } // do not add separator after the last character - if ($append && ($i != strlen($string)-1)) { + if ($append && ($i != $str_len - 1)) { $format_string .= $Separator; } } @@ -2536,7 +2537,7 @@ function PMA_cacheUnset($var, $server = 0) */ function PMA_printable_bit_value($value, $length) { $printable = ''; - for ($i = 0; $i < ceil($length / 8); $i++) { + for ($i = 0, $len_ceiled = ceil($length / 8); $i < $len_ceiled; $i++) { $printable .= sprintf('%08d', decbin(ord(substr($value, $i, 1)))); } $printable = substr($printable, -$length); diff --git a/pmd_common.php b/pmd_common.php index f23c53424..9205349aa 100644 --- a/pmd_common.php +++ b/pmd_common.php @@ -94,7 +94,7 @@ function get_tab_info() { PMA_DBI_select_db($GLOBALS['db']); $tab_column = array(); - for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) { + for ($i = 0, $cnt = count($GLOBALS['PMD']["TABLE_NAME"]); $i < $cnt; $i++) { $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM '.PMA_backquote($GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]), NULL, PMA_DBI_QUERY_STORE); $j = 0; while ($row = PMA_DBI_fetch_assoc($fields_rs)) { @@ -163,7 +163,7 @@ function get_script_contr() '