diff options
author | Andrey Hristov <andrey@php.net> | 2015-11-10 16:59:34 +0100 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2015-11-12 16:19:16 +0100 |
commit | c24d452f6046b5d1b415aa0438ef71fa35ae843f (patch) | |
tree | ab5966c5a6cb18dec2e1898d4aacee5b1f5871d8 /ext/mysqlnd/mysqlnd_ps_codec.c | |
parent | 94ce013bff1e81b218bbb4100cd3267e23f90158 (diff) | |
download | php-git-c24d452f6046b5d1b415aa0438ef71fa35ae843f.tar.gz |
MNDR:
- less dereferencing in mysqlnd_ps . Dereference stmt->conn only once and
use a stack variable. Also make the source cleaner.
Diffstat (limited to 'ext/mysqlnd/mysqlnd_ps_codec.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd_ps_codec.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index 733aad187e..11f00b1cca 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -55,8 +55,8 @@ struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1]; /* {{{ ps_fetch_from_1_to_8_bytes */ void -ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, - zend_uchar ** row, unsigned int byte_count) +ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, + const zend_uchar ** row, unsigned int byte_count) { char tmp[22]; size_t tmp_len = 0; @@ -128,7 +128,7 @@ ps_fetch_from_1_to_8_bytes(zval * zv, const MYSQLND_FIELD * const field, unsigne /* {{{ ps_fetch_null */ static void -ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { ZVAL_NULL(zv); } @@ -137,7 +137,7 @@ ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field, unsigned int pack_len /* {{{ ps_fetch_int8 */ static void -ps_fetch_int8(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_int8(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 1); } @@ -146,7 +146,7 @@ ps_fetch_int8(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_le /* {{{ ps_fetch_int16 */ static void -ps_fetch_int16(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_int16(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 2); } @@ -155,7 +155,7 @@ ps_fetch_int16(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_l /* {{{ ps_fetch_int32 */ static void -ps_fetch_int32(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_int32(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 4); } @@ -164,7 +164,7 @@ ps_fetch_int32(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_l /* {{{ ps_fetch_int64 */ static void -ps_fetch_int64(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_int64(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, 8); } @@ -173,7 +173,7 @@ ps_fetch_int64(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_l /* {{{ ps_fetch_float */ static void -ps_fetch_float(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_float(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { float fval; double dval; @@ -196,7 +196,7 @@ ps_fetch_float(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_l /* {{{ ps_fetch_double */ static void -ps_fetch_double(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_double(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { double value; DBG_ENTER("ps_fetch_double"); @@ -211,7 +211,7 @@ ps_fetch_double(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_ /* {{{ ps_fetch_time */ static void -ps_fetch_time(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_time(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { struct st_mysqlnd_time t; zend_ulong length; /* First byte encodes the length*/ @@ -219,7 +219,7 @@ ps_fetch_time(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_le DBG_ENTER("ps_fetch_time"); if ((length = php_mysqlnd_net_field_length(row))) { - zend_uchar * to= *row; + const zend_uchar * to = *row; t.time_type = MYSQLND_TIMESTAMP_TIME; t.neg = (zend_bool) to[0]; @@ -254,7 +254,7 @@ ps_fetch_time(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_le /* {{{ ps_fetch_date */ static void -ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { struct st_mysqlnd_time t = {0}; zend_ulong length; /* First byte encodes the length*/ @@ -262,10 +262,10 @@ ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_le DBG_ENTER("ps_fetch_date"); if ((length = php_mysqlnd_net_field_length(row))) { - zend_uchar *to= *row; + const zend_uchar * to = *row; - t.time_type= MYSQLND_TIMESTAMP_DATE; - t.neg= 0; + t.time_type = MYSQLND_TIMESTAMP_DATE; + t.neg = 0; t.second_part = t.hour = t.minute = t.second = 0; @@ -291,7 +291,7 @@ ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_le /* {{{ ps_fetch_datetime */ static void -ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { struct st_mysqlnd_time t; zend_ulong length; /* First byte encodes the length*/ @@ -299,10 +299,10 @@ ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, unsigned int pac DBG_ENTER("ps_fetch_datetime"); if ((length = php_mysqlnd_net_field_length(row))) { - zend_uchar * to = *row; + const zend_uchar * to = *row; t.time_type = MYSQLND_TIMESTAMP_DATETIME; - t.neg = 0; + t.neg = 0; t.year = (unsigned int) sint2korr(to); t.month = (unsigned int) to[2]; @@ -335,7 +335,7 @@ ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, unsigned int pac /* {{{ ps_fetch_string */ static void -ps_fetch_string(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_string(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { /* For now just copy, before we make it possible @@ -355,9 +355,9 @@ ps_fetch_string(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_ /* {{{ ps_fetch_bit */ static void -ps_fetch_bit(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row) +ps_fetch_bit(zval * zv, const MYSQLND_FIELD * const field, const unsigned int pack_len, const zend_uchar ** row) { - zend_ulong length = php_mysqlnd_net_field_length(row); + const zend_ulong length = php_mysqlnd_net_field_length(row); ps_fetch_from_1_to_8_bytes(zv, field, pack_len, row, length); } /* }}} */ @@ -551,7 +551,7 @@ mysqlnd_stmt_execute_check_n_enlarge_buffer(zend_uchar **buf, zend_uchar **p, si size_t left = (*buf_len - (*p - *buf)); if (left < (needed_bytes + overalloc)) { - size_t offset = *p - *buf; + const size_t offset = *p - *buf; zend_uchar *tmp_buf; *buf_len = offset + needed_bytes + overalloc; tmp_buf = mnd_emalloc(*buf_len); @@ -578,7 +578,7 @@ mysqlnd_stmt_execute_prepare_param_types(MYSQLND_STMT_DATA * stmt, zval ** copie unsigned int i; DBG_ENTER("mysqlnd_stmt_execute_prepare_param_types"); for (i = 0; i < stmt->param_count; i++) { - short current_type = stmt->param_bind[i].type; + const short current_type = stmt->param_bind[i].type; zval *parameter = &stmt->param_bind[i].zv; ZVAL_DEREF(parameter); @@ -810,7 +810,7 @@ mysqlnd_stmt_execute_store_param_values(MYSQLND_STMT_DATA * stmt, zval * copies, case MYSQL_TYPE_VAR_STRING: send_string: { - size_t len = Z_STRLEN_P(data); + const size_t len = Z_STRLEN_P(data); /* to is after p. The latter hasn't been moved */ *p = php_mysqlnd_net_store_length(*p, len); memcpy(*p, Z_STRVAL_P(data), len); |