Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82105 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64799 invoked from network); 8 Feb 2015 00:35:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2015 00:35:58 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.21 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.21 mout.gmx.net Received: from [212.227.17.21] ([212.227.17.21:63711] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E1/F1-50836-C6FA6D45 for ; Sat, 07 Feb 2015 19:35:57 -0500 Received: from [192.168.0.100] ([91.67.244.80]) by mail.gmx.com (mrgmx101) with ESMTPSA (Nemesis) id 0LvQkh-1XbsOR2i15-010fbo; Sun, 08 Feb 2015 01:35:52 +0100 Message-ID: <54D6AF67.7050003@gmx.de> Date: Sun, 08 Feb 2015 01:35:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Oleg Serov , internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Rd4/0DwDal87U3p7lnyEPNiYUloHaHZoHt1afyFLMvgHElnHnvg 77FtyqK3viyhv969Yo5nNbzo0gBg5aiaaBUPRGOPsku29qgzya4FTxMHXG4RrM8T++FMbUt oh8tfcbb6/3/cl6rfeGckAYCMhykLVmW3Ey4PKB/KeY7HI6hUG54A1Sl0ZU9XFqfINmzMgJ KfGMhIHOAAu0YhQbl+T1A== X-UI-Out-Filterresults: notjunk:1; Subject: Re: Idea of optimizing php !empty(...) expression. From: cmbecker69@gmx.de (Christoph Becker) Oleg Serov wrote: > I use !empty() very often and decided to make a benchmark test. > > Here is the code and results: http://pastebin.com/fMhhdQiW > > if (!empty(...)) working on 23% slower than if (empty()) expression. > > So if create new operator not_empty() it will improve performance. > > The first question is: What do you think about optimizing !empty(...), do > we need it ? > > And I see two way to make this happen. > > 1. Create new language entity "not_empty". > 2. Improve parser and help to handle "!empty" calls different way. > > It is obviously that option 2 is better. Is it real to optimize parser that > way? I see a third way: optimize this on the OPcode level, i.e. BOOL_NOT(X) + JMPZ(T) -> NOP, JMPNZ(X). That is already done by OPcache[1]. [1] -- Christoph M. Becker