Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100474 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76996 invoked from network); 8 Sep 2017 18:17:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2017 18:17:13 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.216.195 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.216.195 mail-qt0-f195.google.com Received: from [209.85.216.195] ([209.85.216.195:36469] helo=mail-qt0-f195.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A1/A1-10715-8AED2B95 for ; Fri, 08 Sep 2017 14:17:12 -0400 Received: by mail-qt0-f195.google.com with SMTP id 7so2004316qtz.3 for ; Fri, 08 Sep 2017 11:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=qeX53OL21opzbeH9gFrT/C1TbBHraXRwtBJMMtgGyj4=; b=Q2ycqJqPtPi3gnfLIVMmE64KmtV5gxAYI1rpBLk7MvLX23xKcG2F65KcFlEEJoZn9T UxdMl95AodNhMnWVf4odfUL3/ruTGf99Tfbv8FEZ+aPci8R59g80vuLynRAobF3+hgSN S2hfPq0+ZTo7rCfHVuz+QczOeJxLYDbVQ4/725fy2aVLpT3de6NRTz5pIdqJiBRiJlu4 WwRQZwoYONJ/VmR9aP0a09R/uYUodH6hdBBBbhtvXyAwFk4BNoUMD9YxPmA9FrD9xFCD dUAwYHu6d1CoFvWqinXFvER80S+NM3osquxq8JbgSYm7TL57xooMF9DyxYlzW3plQkpK yrJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=qeX53OL21opzbeH9gFrT/C1TbBHraXRwtBJMMtgGyj4=; b=q59gigroAraxgjNBDjEe8ieUdW0FhNicT8QDSde6m1SnKn+h1tzwriGIvQuv/VEsxg XQWWfYyugPQfxidXb50OtMhCzr81ME32vp1nZ8CdsIhTVKV60KOIk/8nikUUZTedaJFi ST/BzQhlnMoENAC3oQK01ZJfYc+nXholHxeuTdNHn5x5BJ6sIltLWJBnJa12O5GitxYH wcwI/6lCo606WEzoqraZYHFsxlkkBcKofFV68/yPAjR9KVM0mwNJljDY6owIeF/Iy56c u4n/LiWE8N8Eb3SyAxzDMo7nzAjuKTmaQ/j8o1Y58uXtENekl/8m5no2mBB/o+xaYKWB CLUA== X-Gm-Message-State: AHPjjUjAxOd1AcNw1FAtLqgvomN+oqT0TDl+uA/iqTsYQ/GRE4sjfwuj 42Ds4/jba0/x3E++ZTH2IIjgbR/SrTeT X-Google-Smtp-Source: AOwi7QA+rxAHmnoylCGKGtqpvjRV52uJOaAnoxpif9ILP1C580+ifxKB4OZzzKFXspXEdnFP5KlYD7K/hNUtEwnFzrQ= X-Received: by 10.237.39.135 with SMTP id a7mr5691328qtd.84.1504894629423; Fri, 08 Sep 2017 11:17:09 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.132.3 with HTTP; Fri, 8 Sep 2017 11:17:08 -0700 (PDT) X-Originating-IP: [173.250.244.34] In-Reply-To: <1504883189.2374.26.camel@schlueters.de> References: <1504883189.2374.26.camel@schlueters.de> Date: Fri, 8 Sep 2017 11:17:08 -0700 X-Google-Sender-Auth: HK6zn9hdr5ns1jTJLhzFKwOBSHs Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: David Rodrigues , PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] array_filter vs for/foreach usage cost From: pollita@php.net (Sara Golemon) On Fri, Sep 8, 2017 at 8:06 AM, Johannes Schl=C3=BCter wrote: > On Do, 2017-09-07 at 15:13 -0300, David Rodrigues wrote: >> I understand that array_filter() should costs more than for/foreach >> because >> it is a function call that call another function for each item, while >> the >> for/foreach is a language constructor that works on a way totally >> different >> and its optimized for this kind of job. > > The main cost in that is that array_filter has to create a copy of the > array. An alternative is using an FilterIterator or generator or such > which would make this a pipeline step. (with iterators there are > multiple function calls, while the function descriptor is cached, > making them relatively cheap) I'd focus on improving those. > *cough* https://github.com/phplang/generator/blob/master/src/iterable.php#L64 *cough* -Sara