Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82108 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80777 invoked from network); 8 Feb 2015 02:50:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2015 02:50:32 -0000 Authentication-Results: pb1.pair.com header.from=serovov@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=serovov@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.178 as permitted sender) X-PHP-List-Original-Sender: serovov@gmail.com X-Host-Fingerprint: 209.85.213.178 mail-ig0-f178.google.com Received: from [209.85.213.178] ([209.85.213.178:54540] helo=mail-ig0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/51-07765-7FEC6D45 for ; Sat, 07 Feb 2015 21:50:31 -0500 Received: by mail-ig0-f178.google.com with SMTP id hl2so10231930igb.5 for ; Sat, 07 Feb 2015 18:50:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=tK923gB7SEIsDm+YgU5CfRuVp2tb23YtIdcLr6QYP2c=; b=do2Zj568W2j++snDxVjXc1x8J8YrIPtkm5niL7LhKDraHSs6M5p0MxFjjZjDUmDMgA QHggBnC73dXT90C/G6JmhCCLvghwMPrxpAoxZySdpW+3g/OvVoRrrXfxg7xeYPnaitV3 ogYN9HfOx0tuPcDxqXlXoe+mnx1ZL5nR6aCP7OyUP7Jmw04i+gcOH8jEbnZNE95KpwEc 4iOFMf+n32ZNrQNZEdHl0J41Vg9vrnHEVxrSwX86M1ANCWhHhJuiiVVceczmlwHTjIXh Pmr5gLXxQXeTLRCCcgeMUVwXooiEXCbEMMrRqBtyrubi10o22yPgxXoUBTsJg2mBeeUN sniw== X-Received: by 10.50.137.99 with SMTP id qh3mr10074551igb.7.1423363829116; Sat, 07 Feb 2015 18:50:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.111.232 with HTTP; Sat, 7 Feb 2015 18:50:08 -0800 (PST) In-Reply-To: <54D6AF67.7050003@gmx.de> References: <54D6AF67.7050003@gmx.de> Date: Sat, 7 Feb 2015 21:50:08 -0500 Message-ID: To: Christoph Becker Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a11c3bcbc6bb8c9050e8ab7b1 Subject: Re: Idea of optimizing php !empty(...) expression. From: serovov@gmail.com (Oleg Serov) --001a11c3bcbc6bb8c9050e8ab7b1 Content-Type: text/plain; charset=UTF-8 Thanks, with enabled opcache works fine. On 7 February 2015 at 19:35, Christoph Becker wrote: > 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] < > http://lxr.php.net/xref/PHP_5_5/ext/opcache/Optimizer/block_pass.c#816> > > -- > Christoph M. Becker > > -- Best Regards, Oleg --001a11c3bcbc6bb8c9050e8ab7b1--