patch #2727250 Optimizations for some PHP loops

This commit is contained in:
Herman van Rink
2009-04-04 12:41:02 +00:00
parent c14dcef57f
commit f0eb21fba8
5 changed files with 15 additions and 11 deletions

View File

@@ -49,6 +49,8 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
thanks to Pawel Smolinski - zipoking thanks to Pawel Smolinski - zipoking
+ patch #2715142 [export] (rfe 2416960, escape new line in CSV export) + patch #2715142 [export] (rfe 2416960, escape new line in CSV export)
thanks to Derek Schaefer - drummingds1 thanks to Derek Schaefer - drummingds1
- patch #2727250 Optimizations for PHP loops
thanks to Haeber
3.1.4.0 (not yet released) 3.1.4.0 (not yet released)
+ patch #1808339 [doc] Apache SSLOptions and StdEnvVars FAQ, + patch #1808339 [doc] Apache SSLOptions and StdEnvVars FAQ,

View File

@@ -813,7 +813,8 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
$group =& $table_groups; $group =& $table_groups;
$i = 0; $i = 0;
$group_name_full = ''; $group_name_full = '';
while ($i < count($parts) - 1 $parts_cnt = count($parts) - 1;
while ($i < $parts_cnt
&& $i < $GLOBALS['cfg']['LeftFrameTableLevel']) { && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) {
$group_name = $parts[$i] . $sep; $group_name = $parts[$i] . $sep;
$group_name_full .= $group_name; $group_name_full .= $group_name;
@@ -1798,7 +1799,7 @@ function PMA_flipstring($string, $Separator = "<br />\n")
$format_string = ''; $format_string = '';
$charbuff = false; $charbuff = false;
for ($i = 0; $i < strlen($string); $i++) { for ($i = 0, $str_len = strlen($string); $i < $str_len; $i++) {
$char = $string{$i}; $char = $string{$i};
$append = false; $append = false;
@@ -1817,7 +1818,7 @@ function PMA_flipstring($string, $Separator = "<br />\n")
} }
// do not add separator after the last character // do not add separator after the last character
if ($append && ($i != strlen($string)-1)) { if ($append && ($i != $str_len - 1)) {
$format_string .= $Separator; $format_string .= $Separator;
} }
} }
@@ -2536,7 +2537,7 @@ function PMA_cacheUnset($var, $server = 0)
*/ */
function PMA_printable_bit_value($value, $length) { function PMA_printable_bit_value($value, $length) {
$printable = ''; $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 .= sprintf('%08d', decbin(ord(substr($value, $i, 1))));
} }
$printable = substr($printable, -$length); $printable = substr($printable, -$length);

View File

@@ -94,7 +94,7 @@ function get_tab_info()
{ {
PMA_DBI_select_db($GLOBALS['db']); PMA_DBI_select_db($GLOBALS['db']);
$tab_column = array(); $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); $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM '.PMA_backquote($GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]), NULL, PMA_DBI_QUERY_STORE);
$j = 0; $j = 0;
while ($row = PMA_DBI_fetch_assoc($fields_rs)) { while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
@@ -163,7 +163,7 @@ function get_script_contr()
'<script type="text/javascript">' . "\n" . '<script type="text/javascript">' . "\n" .
'// <![CDATA[' . "\n" . '// <![CDATA[' . "\n" .
'var contr = new Array();' . "\n"; 'var contr = new Array();' . "\n";
for ($i = 0; $i < count($con["C_NAME"]); $i++) { for ($i = 0, $cnt = count($con["C_NAME"]); $i < $cnt; $i++) {
$js_var = ' contr[' . $ti . ']'; $js_var = ' contr[' . $ti . ']';
$script_contr .= $js_var . " = new Array();\n"; $script_contr .= $js_var . " = new Array();\n";
$js_var .= "['" . $con['C_NAME'][$i] . "']"; $js_var .= "['" . $con['C_NAME'][$i] . "']";
@@ -241,7 +241,7 @@ function get_script_tabs()
'<script type="text/javascript">' . "\n" . '<script type="text/javascript">' . "\n" .
'// <![CDATA[' . "\n" . '// <![CDATA[' . "\n" .
'var j_tabs = new Array();' . "\n"; 'var j_tabs = new Array();' . "\n";
for ($i = 0; $i < count($GLOBALS['PMD']['TABLE_NAME']); $i++) { for ($i = 0, $cnt = count($GLOBALS['PMD']['TABLE_NAME']); $i < $cnt; $i++) {
$script_tabs .= "j_tabs['" . $GLOBALS['PMD_URL']['TABLE_NAME'][$i] . "'] = '" $script_tabs .= "j_tabs['" . $GLOBALS['PMD_URL']['TABLE_NAME'][$i] . "'] = '"
. (PMA_foreignkey_supported($GLOBALS['PMD']['TABLE_TYPE'][$i]) ? '1' : '0') . "';\n"; . (PMA_foreignkey_supported($GLOBALS['PMD']['TABLE_TYPE'][$i]) ? '1' : '0') . "';\n";
} }

View File

@@ -137,7 +137,8 @@ echo $script_tabs . $script_contr . $script_display_field;
<div id="id_scroll_tab" class="scroll_tab"> <div id="id_scroll_tab" class="scroll_tab">
<table width="100%" style="padding-left: 3px;"> <table width="100%" style="padding-left: 3px;">
<?php <?php
for ($i = 0; $i < count($GLOBALS['PMD']['TABLE_NAME']); $i++) { $name_cnt = count($GLOBALS['PMD']['TABLE_NAME']);
for ($i = 0; $i < $name_cnt; $i++) {
?> ?>
<tr><td title="<?php echo $strStructure; ?>" width="1px" <tr><td title="<?php echo $strStructure; ?>" width="1px"
onmouseover="this.className='L_butt2_2'" onmouseover="this.className='L_butt2_2'"
@@ -169,7 +170,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']['TABLE_NAME']); $i++) {
</div> </div>
<div align="center"> <div align="center">
<?php echo $strNumberOfTables ?>: <?php echo count($GLOBALS['PMD']['TABLE_NAME']) ?> <?php echo $strNumberOfTables . ': ' . $name_cnt; ?>
</div> </div>
<div align="right"> <div align="right">
<div id="layer_menu_sizer" onmousedown="layer_menu_cur_click=1"> <div id="layer_menu_sizer" onmousedown="layer_menu_cur_click=1">
@@ -227,7 +228,7 @@ for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
<?php if (! isset($tab_pos[$t_n])) echo 'style="display: none;"'; ?>> <?php if (! isset($tab_pos[$t_n])) echo 'style="display: none;"'; ?>>
<?php <?php
$display_field = PMA_getDisplayField($db, $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]); $display_field = PMA_getDisplayField($db, $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]);
for ($j = 0; $j < count($tab_column[$t_n]["COLUMN_ID"]); $j++) { for ($j = 0, $id_cnt = count($tab_column[$t_n]["COLUMN_ID"]); $j < $id_cnt; $j++) {
?> ?>
<tr id="id_tr_<?php <tr id="id_tr_<?php
echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . '.' echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . '.'

View File

@@ -255,7 +255,7 @@ function perform_config_checks()
$blowfish_secret = $cf->get('blowfish_secret'); $blowfish_secret = $cf->get('blowfish_secret');
$blowfish_secret_set = false; $blowfish_secret_set = false;
$cookie_auth_used = false; $cookie_auth_used = false;
for ($i = 1; $i <= $cf->getServerCount(); $i++) { for ($i = 1, $server_cnt = $cf->getServerCount(); $i <= $server_cnt; $i++) {
$cookie_auth_server = ($cf->getValue("Servers/$i/auth_type") == 'cookie'); $cookie_auth_server = ($cf->getValue("Servers/$i/auth_type") == 'cookie');
$cookie_auth_used |= $cookie_auth_server; $cookie_auth_used |= $cookie_auth_server;
$server_name = $cf->getServerName($i); $server_name = $cf->getServerName($i);