diff options
author | Joe Watkins <krakjoe@php.net> | 2017-07-25 06:47:58 +0100 |
---|---|---|
committer | Joe Watkins <krakjoe@php.net> | 2017-07-25 06:47:58 +0100 |
commit | 69b48f83dfc287a8430cf8e993d0937c5128623f (patch) | |
tree | 42f190d508c3d369b3caa225bc1fac218c44e56f | |
parent | cdf9178c4348316fd53bebe598a0752a4827e2bd (diff) | |
download | php-git-69b48f83dfc287a8430cf8e993d0937c5128623f.tar.gz |
minor loop optimizations, closes #2633
-rw-r--r-- | ext/mysqli/mysqli.c | 5 | ||||
-rw-r--r-- | ext/mysqli/mysqli_api.c | 10 | ||||
-rw-r--r-- | win32/sendmail.c | 7 |
3 files changed, 15 insertions, 7 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 04f07a5c93..d26f32d652 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -1156,7 +1156,7 @@ void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend { #if !defined(MYSQLI_USE_MYSQLND) MYSQL_ROW row; - unsigned int i; + unsigned int i, num_fields; MYSQL_FIELD *fields; zend_ulong *field_len; @@ -1170,8 +1170,9 @@ void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend array_init(return_value); field_len = mysql_fetch_lengths(result); + num_fields = mysql_num_fields(result); - for (i = 0; i < mysql_num_fields(result); i++) { + for (i = 0; i < num_fields; i++) { if (row[i]) { zval res; diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index ffdcdaf140..6793fc8065 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1210,7 +1210,7 @@ PHP_FUNCTION(mysqli_fetch_fields) zval *mysql_result; zval obj; - unsigned int i; + unsigned int i, num_fields; if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { return; @@ -1219,8 +1219,9 @@ PHP_FUNCTION(mysqli_fetch_fields) MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); array_init(return_value); + num_fields = mysql_num_fields(result); - for (i = 0; i < mysql_num_fields(result); i++) { + for (i = 0; i < num_fields; i++) { const MYSQL_FIELD *field = mysql_fetch_field_direct(result, i); object_init(&obj); @@ -1266,7 +1267,7 @@ PHP_FUNCTION(mysqli_fetch_lengths) { MYSQL_RES *result; zval *mysql_result; - unsigned int i; + unsigned int i, num_fields; zend_ulong *ret; if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { @@ -1280,8 +1281,9 @@ PHP_FUNCTION(mysqli_fetch_lengths) } array_init(return_value); + num_fields = mysql_num_fields(result); - for (i = 0; i < mysql_num_fields(result); i++) { + for (i = 0; i < num_fields; i++) { add_index_long(return_value, i, ret[i]); } } diff --git a/win32/sendmail.c b/win32/sendmail.c index d83663a475..808fc8f5fd 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -698,10 +698,15 @@ static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders) size_t i; if (xheaders) { + size_t headers_lc_len; + if (NULL == (headers_lc = estrdup(xheaders))) { return OUT_OF_MEMORY; } - for (i = 0; i < strlen(headers_lc); i++) { + + headers_lc_len = strlen(headers_lc); + + for (i = 0; i < headers_lc_len; i++) { headers_lc[i] = tolower(headers_lc[i]); } } |