Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85212 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45257 invoked from network); 19 Mar 2015 10:51:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2015 10:51:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patrickallaert@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:37132] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/C1-32681-D2AAA055 for ; Thu, 19 Mar 2015 05:51:25 -0500 Received: by wixw10 with SMTP id w10so65348681wix.0 for ; Thu, 19 Mar 2015 03:51:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=M5a4d3viWbG9Zs3kcz0Ar4wKLgPLERD9uWdAy7qWL/k=; b=VX36g54th6uQsvYm/lZzTbG7tB+pNfb6ur3t3PbOKcMjIRxsm+PDbmulU4vckSTe4Z BgXHeQbGpVCG6JArHBsvju+x033K4Fjsj7v8qfzHBYSB+73nVa5M0aKEsMoJIBzoaBlP 9qVJzIswmBpCOZR4sXcmKkloFlK6a3C+DoOB0olIOHtRigwx34TVvHLA2O31cCeDboJt 1BY0EyS6VNIBn2yerNhAc2Rn6QDoK+qhzNwXZK/VC1Cm1tn1bPbnsjxSPaS8k0yEQSWC Kegd1IXoE1sG7lWn6vBhrNlWxxNKv4r03Me8SvmXV3Uij70nV+TOUEoGiJqL7RD5MyrD WaQg== X-Received: by 10.181.25.225 with SMTP id it1mr15225404wid.8.1426762281911; Thu, 19 Mar 2015 03:51:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 19 Mar 2015 10:51:21 +0000 Message-ID: To: Niklas Keller , PHP Internals Content-Type: multipart/alternative; boundary=001a11360a2cfe0bd20511a1fa17 Subject: Re: [PHP-DEV] [RFC][PRE-VOTE] In Operator From: patrickallaert@php.net (Patrick ALLAERT) --001a11360a2cfe0bd20511a1fa17 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hey, Le dim. 15 mars 2015 =C3=A0 01:54, Niklas Keller a =C3=A9c= rit : > Morning, > > I'd like to announce that I'll open the vote for the in operator later > that day. > You can find the RFC here: https://wiki.php.net/rfc/in_operator > > There was a small change: If the haystack is a string, integers are no > longer allowed as needle. This change was necessary so it's > consistently strict for both, array and string haystacks. > > Regards, Niklas > If there is one thing that can be improved in a related area: create a true "Set" datatype. You just don't imagine how often I encountered bottlenecks in PHP application where in_array() was used (thousands times per request over not so small arrays). Sometimes it can be improved by storing the value in the key part (using an array to emulate a hash thanks to the internal implementation of arrays), using SplObjectStorage in case of objects or even a bloom filter implementation [1]. Visit [2] for some inspirations. As you see , there is room for improvement to make things easier, but that wouldn't be by simply be achieved by adding an "in" keyword. Everytime I see an in_array(), I also cry, but not because of the syntax, rather because I know how it operates (think: "full table scan" if you were doing a SELECT query without proper indexes). This simply cannot be improved in a proper way without a true "Set" implementation. [1] http://pecl.php.net/package/bloomy [2] http://technosophos.com/2009/05/29/set-objects-php-arrays-vs-splobjectstora= ge.html Cheers, Patrick --001a11360a2cfe0bd20511a1fa17--