Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42119 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80743 invoked from network); 6 Dec 2008 02:21:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Dec 2008 02:21:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=igor.feghali@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=igor.feghali@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.170.184 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: igor.feghali@gmail.com X-Host-Fingerprint: 64.233.170.184 rn-out-0910.google.com Received: from [64.233.170.184] ([64.233.170.184:27167] helo=rn-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/85-01047-4A1E9394 for ; Fri, 05 Dec 2008 21:21:25 -0500 Received: by rn-out-0910.google.com with SMTP id k40so337358rnd.0 for ; Fri, 05 Dec 2008 18:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=WrKBpOplXb13VY8fI4IxuUBJ/ucDSjE5org2h2qMt1g=; b=qodUWyTsW1IdPh7tneG1mU4IkzcMBoFcpAkm7pW+pKa4SL9NS2mlmh1fqDo72z3e+8 nyBnQhATeU1zySAwOx59+SYBhc1rEhmMgmvZ9RU+ljPeEOumcrxkXufyHE2e4+6zj2Zm 1eHN5gTn6vFXpNjseqzY86pFvyPGvtdvyUAVM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=jY8dnrJ+qnQGZ6Y4ktYHkwzMS+UqIszNcEOfNhvExPUgvxWKbtxbzoPopqfZBNQCuK bYx/HWIo1KTKooRrWDyULfy6UqzezaBOUxA5M4uFklYv/It/oKmlytK3slAWK9DnIjX0 vOXvfQftMwfhkLawiDzVjov39mEBk+3/CikhY= Received: by 10.150.121.2 with SMTP id t2mr1897464ybc.83.1228530081717; Fri, 05 Dec 2008 18:21:21 -0800 (PST) Received: by 10.150.157.16 with HTTP; Fri, 5 Dec 2008 18:21:21 -0800 (PST) Message-ID: Date: Sat, 6 Dec 2008 00:21:21 -0200 To: "PHP Internals List" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_25571_12489736.1228530081694" Subject: Implode() FR and Patch From: igor.feghali@gmail.com ("Igor Feghali") ------=_Part_25571_12489736.1228530081694 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello There, I would like to propose a third argument to implode(), named skip_empty, that will cause empty elements to be ignored when generating the implode string. By empty I mean everything that converts to an empty string such as '', false, null, etc. For example: Will output: 1,,2,,3,0,4,1,5,, 1,2,3,0,4,1,5 Obviously the new parameter defaults to 'false' for backwards compatibility. The patch file is attached for evaluation, review, feedback etc. Please keep in mind that this is my first time playing with PHP source so expect flaws on my code. I did a few simple tests (using `time`, if someone has a non buggy valgrind for OS X please let me know) against 5.3 CVS (named php53 in examples) and my patched version (named php+ in examples). The PHP scripts are right below the tests. Looking at the results I would say there is almost no performance loss. Before I place a feature request at PHP.net I would love to hear some feedback here, or even a yes/no for this feature. Best Regards, Igor Feghali. === TEST 1 === $ time ./php53 /tmp/more_small.php real 0m0.257s user 0m0.223s sys 0m0.032s $ time ./php53 /tmp/more_small.php real 0m0.258s user 0m0.224s sys 0m0.032s $ time ./php53 /tmp/more_small.php real 0m0.260s user 0m0.225s sys 0m0.032s $ time ./php+ /tmp/more_small.php real 0m0.261s user 0m0.226s sys 0m0.033s $ time ./php+ /tmp/more_small.php real 0m0.258s user 0m0.224s sys 0m0.032s $ time ./php+ /tmp/more_small.php real 0m0.260s user 0m0.225s sys 0m0.033s === TEST 2 === $ time ./php53 /tmp/less_big.php real 0m0.328s user 0m0.205s sys 0m0.120s $ time ./php53 /tmp/less_big.php real 0m0.328s user 0m0.206s sys 0m0.120s $ time ./php53 /tmp/less_big.php real 0m0.326s user 0m0.205s sys 0m0.119s $ time ./php+ /tmp/less_big.php real 0m0.330s user 0m0.206s sys 0m0.122s $ time ./php+ /tmp/less_big.php real 0m0.330s user 0m0.206s sys 0m0.121s $ time ./php+ /tmp/less_big.php real 0m0.333s user 0m0.207s sys 0m0.124s === TEST 3 === $ time ./php+ /tmp/lots_null.php real 0m0.263s user 0m0.229s sys 0m0.032s $ time ./php+ /tmp/lots_null.php real 0m0.261s user 0m0.227s sys 0m0.032s $ time ./php+ /tmp/lots_null.php real 0m0.260s user 0m0.226s sys 0m0.032s $ time ./php+ /tmp/no_null.php real 0m0.259s user 0m0.226s sys 0m0.032s $ time ./php+ /tmp/no_null.php real 0m0.257s user 0m0.223s sys 0m0.031s $ time ./php+ /tmp/no_null.php real 0m0.264s user 0m0.229s sys 0m0.032s === SCRIPTS === less_big.php