mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
10-18% optimization of fetch_array(), when both number & string indexes are
created. # Do we want to MFH the change (for ext/mysql) into 4.3.X?
This commit is contained in:
parent
f3d385a587
commit
d9bf51b17c
2 changed files with 25 additions and 25 deletions
|
@ -1932,26 +1932,25 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
|
|||
mysql_field_seek(mysql_result, 0);
|
||||
for (mysql_field=mysql_fetch_field(mysql_result), i=0; mysql_field; mysql_field=mysql_fetch_field(mysql_result), i++) {
|
||||
if (mysql_row[i]) {
|
||||
char *data;
|
||||
int data_len;
|
||||
int should_copy;
|
||||
zval *data;
|
||||
|
||||
MAKE_STD_ZVAL(data);
|
||||
|
||||
if (PG(magic_quotes_runtime)) {
|
||||
data = php_addslashes(mysql_row[i], mysql_row_lengths[i],&data_len, 0 TSRMLS_CC);
|
||||
should_copy = 0;
|
||||
Z_TYPE_P(data) = IS_STRING;
|
||||
Z_STRVAL_P(data) = php_addslashes(mysql_row[i], mysql_row_lengths[i], &Z_STRLEN_P(data), 0 TSRMLS_CC);
|
||||
} else {
|
||||
data = mysql_row[i];
|
||||
data_len = mysql_row_lengths[i];
|
||||
should_copy = 1;
|
||||
ZVAL_STRINGL(data, mysql_row[i], mysql_row_lengths[i], 1);
|
||||
}
|
||||
|
||||
|
||||
if (result_type & MYSQL_NUM) {
|
||||
add_index_stringl(return_value, i, data, data_len, should_copy);
|
||||
should_copy = 1;
|
||||
add_index_zval(return_value, i, data);
|
||||
}
|
||||
|
||||
if (result_type & MYSQL_ASSOC) {
|
||||
add_assoc_stringl(return_value, mysql_field->name, data, data_len, should_copy);
|
||||
if (result_type & MYSQL_NUM) {
|
||||
ZVAL_ADDREF(data);
|
||||
}
|
||||
add_assoc_zval(return_value, mysql_field->name, data);
|
||||
}
|
||||
} else {
|
||||
/* NULL value. */
|
||||
|
|
|
@ -375,7 +375,6 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
|
|||
MYSQL_RES *result;
|
||||
zval *mysql_result;
|
||||
int fetchtype;
|
||||
int copyflag;
|
||||
unsigned int i;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_ROW row;
|
||||
|
@ -430,24 +429,26 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
|
|||
|
||||
for (i = 0; i < mysql_num_fields(result); i++) {
|
||||
if (row[i]) {
|
||||
char *column;
|
||||
int column_len;
|
||||
|
||||
zval *res;
|
||||
|
||||
MAKE_STD_ZVAL(res);
|
||||
|
||||
/* check if we need magic quotes */
|
||||
if (PG(magic_quotes_runtime)) {
|
||||
column = php_addslashes(row[i], field_len[i], &column_len, 0 TSRMLS_CC);
|
||||
copyflag = 0;
|
||||
Z_TYPE_P(res) = IS_STRING;
|
||||
Z_STRVAL_P(res) = php_addslashes(row[i], field_len[i], &Z_STRLEN_P(res), 0 TSRMLS_CC);
|
||||
} else {
|
||||
column = row[i];
|
||||
column_len = field_len[i];
|
||||
copyflag = 1;
|
||||
ZVAL_STRINGL(res, row[i], field_len[i], 1);
|
||||
}
|
||||
|
||||
if (fetchtype & MYSQLI_NUM) {
|
||||
add_index_stringl(return_value, i, column, column_len, copyflag);
|
||||
copyflag = 1;
|
||||
add_index_zval(return_value, i, res);
|
||||
}
|
||||
if (fetchtype & MYSQLI_ASSOC) {
|
||||
add_assoc_stringl(return_value, fields[i].name, column, column_len, copyflag);
|
||||
if (fetchtype & MYSQLI_NUM) {
|
||||
ZVAL_ADDREF(res);
|
||||
}
|
||||
add_assoc_zval(return_value, fields[i].name, res);
|
||||
}
|
||||
} else {
|
||||
if (fetchtype & MYSQLI_NUM) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue