Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10432 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49097 invoked by uid 1010); 14 Jun 2004 09:00:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 49073 invoked from network); 14 Jun 2004 09:00:36 -0000 Received: from unknown (HELO jdi.jdimedia.nl) (212.204.192.51) by pb1.pair.com with SMTP; 14 Jun 2004 09:00:36 -0000 Received: from localhost (localhost [127.0.0.1]) by jdi.jdimedia.nl (8.12.10/8.12.10) with ESMTP id i5E90YH2032610; Mon, 14 Jun 2004 11:00:34 +0200 Date: Mon, 14 Jun 2004 11:00:33 +0200 (CEST) X-X-Sender: derick@localhost To: Alexander Valyalkin cc: internals@lists.php.net In-Reply-To: Message-ID: References: <40CC1D3C.9070605@php.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Re: crc32() improvements From: derick@php.net (Derick Rethans) On Mon, 14 Jun 2004, Alexander Valyalkin wrote: > Thank you for good explanation and comments. > Now I understood that the current crc32 implementation is better than mine. > But it consists some ugly bugs (read my comments): > PHP_NAMED_FUNCTION(php_if_crc32) > { > unsigned int crc = ~0; > char *p; > int len, nr; /*!!! is special sense in [len] var here? Remove it! */ > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p, &nr) == > FAILURE) { > return; > } > /* !!! there is no error check nr < 0 */ Of course not, that's pointless as a string can never have a negative length. > len = 0 ; /* !!! remove it! */ Why? It's used one line below and you HAVE to initalize a variable. > for (len += nr; nr--; ++p) { > CRC32(crc, *p); > } > RETVAL_LONG(~crc); > } > > Below is corrected function with speed improvement in main cycle It also violates our coding standards BIG time. And there is no reason to expand that macro at all, nor is your code regarding the || nr <0 needed. Please STOP wasting our time with those silly improvements which aren't improvements. You're wasting our and your own time. Derick k