Re: [PHP-DEV] CVS update: php3/functions From: Zeev Suraski (zeev <email protected>)
Date: 12/28/98

Unless I'm missing something, I'm against this patch. The optimizations
seem to be trivial enough for any optimizing compiler to do them by itself;
 The real problem is that it seems to change the behavior of the function
altogether (an empty element is returned for a NULL field, instead of that
element being unset).

Zeev

At 13:41 28/12/98 -0500, sas wrote:
>Date: Monday December 28, 1998 @ 13:41
>Author: sas
>
>Update of /repository/php3/functions
>In directory asf:/u/temp/cvs-serv6343/functions
>
>Modified Files:
> pgsql.c
>Log Message:
>save some bytes and unnecessary copies
>
>Index: php3/functions/pgsql.c
>diff -c php3/functions/pgsql.c:1.76 php3/functions/pgsql.c:1.77
>*** php3/functions/pgsql.c:1.76 Mon Dec 28 12:37:43 1998
>--- php3/functions/pgsql.c Mon Dec 28 13:41:01 1998
>***************
>*** 28,34 ****
> +----------------------------------------------------------------------+
> */
>
>! /* $Id: pgsql.c,v 1.76 1998/12/28 17:37:43 sas Exp $ */
>
> #include <stdlib.h>
>
>--- 28,34 ----
> +----------------------------------------------------------------------+
> */
>
>! /* $Id: pgsql.c,v 1.77 1998/12/28 18:41:01 sas Exp $ */
>
> #include <stdlib.h>
>
>***************
>*** 903,923 ****
> }
> array_init(return_value);
> for (i=0,num_fields=PQnfields(pgsql_result); i<num_fields; i++) {
> element = PQgetvalue(pgsql_result,row->value.lval,i);
>! element_len = (element ? strlen(element) : 0);
>! element = safe_estrndup(element,element_len);
>! if (element) {
>! if (php3_ini.magic_quotes_runtime) {
>! char
*tmp=_php3_addslashes(element,element_len,&element_len,0);
>!
>! add_index_stringl(return_value, i, tmp, element_len, 0);
>! } else {
>! add_index_stringl(return_value, i, element, element_len,
1);
>! }
>! } else {
>! /* NULL field, don't set it */
>! /*add_index_stringl(return_value, i, empty_string, 0, 1);*/
>! }
> }
> }
> /* }}} */
>--- 903,923 ----
> }
> array_init(return_value);
> for (i=0,num_fields=PQnfields(pgsql_result); i<num_fields; i++) {
>+ char *tmp;
>+
> element = PQgetvalue(pgsql_result,row->value.lval,i);
>! if (element) {
>! element_len = strlen(element);
>! if (php3_ini.magic_quotes_runtime) {
>! tmp = _php3_addslashes(element, element_len, &element_len, 0);
>! } else {
>! tmp = estrndup(element, element_len);
>! }
>! } else {
>! tmp = estrdup(empty_string);
>! element_len = 0;
>! }
>! add_index_stringl(return_value, i, tmp, element_len, 0);
> }
> }
> /* }}} */
>***************
>*** 953,975 ****
> }
> array_init(return_value);
> for (i=0,num_fields=PQnfields(pgsql_result); i<num_fields; i++) {
> element = PQgetvalue(pgsql_result,row->value.lval,i);
>- element_len = (element ? strlen(element) : 0);
>- element = safe_estrndup(element,element_len);
> if (element) {
>! if (php3_ini.magic_quotes_runtime) {
>! char
*tmp=_php3_addslashes(element,element_len,&element_len,0);
>
>! add_get_index_stringl(return_value, i, tmp, element_len,
(void **) &pval_ptr, 0);
>! } else {
>! add_get_index_stringl(return_value, i, element,
element_len, (void **) &pval_ptr, 0);
>! }
>! field_name = PQfname(pgsql_result,i);
>! _php3_hash_pointer_update(return_value->value.ht,
field_name, strlen(field_name)+1, pval_ptr);
>! } else {
>! /* NULL field, don't set it */
>! /* add_get_index_stringl(return_value, i, empty_string, 0,
(void **) &pval_ptr); */
>! }
> }
> }
>
>--- 953,976 ----
> }
> array_init(return_value);
> for (i=0,num_fields=PQnfields(pgsql_result); i<num_fields; i++) {
>+ char *tmp;
>+
> element = PQgetvalue(pgsql_result,row->value.lval,i);
> if (element) {
>! element_len = strlen(element);
>! if (php3_ini.magic_quotes_runtime) {
>! tmp = _php3_addslashes(element, element_len, &element_len, 0);
>! } else {
>! tmp = estrndup(element, element_len);
>! }
>! } else {
>! tmp = estrdup(empty_string);
>! element_len = 0;
>! }
>
>! add_get_index_stringl(return_value, i, tmp, element_len, (void **)
&pval_ptr, 0);
>! field_name = PQfname(pgsql_result, i);
>! _php3_hash_pointer_update(return_value->value.ht, field_name,
strlen(field_name)+1, pval_ptr);
> }
> }
>
>
>--
>PHP Development Mailing List http://www.php.net/
>To unsubscribe send an empty message to php-dev-unsubscribe <email protected>
>For help: php-dev-help <email protected>
>
>
>

--
Zeev Suraski   <zeev <email protected>>
For a PGP public key, finger bourbon <email protected>

-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>