Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98965 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11919 invoked from network); 4 May 2017 15:52:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2017 15:52:17 -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 74.125.82.53 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 74.125.82.53 mail-wm0-f53.google.com Received: from [74.125.82.53] ([74.125.82.53:38591] helo=mail-wm0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/56-02776-E2E4B095 for ; Thu, 04 May 2017 11:52:16 -0400 Received: by mail-wm0-f53.google.com with SMTP id 142so238756wma.1 for ; Thu, 04 May 2017 08:52:14 -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; bh=g+IVUgqccbJ5joMvdB8FvSmOh+CVS9Sk+nW/E4w24p0=; b=CzuTdLwlHjBdqglV5UzsC1HvOqKR0DZwY835S8HufgugJgcrVUHaDq/7utaSX9QNYv YGVKlcggi3soJOv0yKTiiLE+YJhiQtLOorNRzEfkaoushLNWiV8RIqTP5nwLDeX8KUTe hroW5mQVaYowO9PFjOKGbKMnB8IgygISL9u4+xB+Idxgyz7FxUOwJO/GV3ZYDUA3MMDw DZUoKz/r7shmV7xKnH7K4rKop2DzaAITw7R/hAlY+8O02gwT1YdpWhDs1PG7/W17yJjw dm/vwPCbXMovGNW5ZZxOaoydNkUMfkmfsccftAsGojZYwsaYMDEBKXFYpD8b6iSWRE3R Ov4A== 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; bh=g+IVUgqccbJ5joMvdB8FvSmOh+CVS9Sk+nW/E4w24p0=; b=uAOsI2+CUmw1kmN90pQj53QrE9FD6I77XeqEvFvwDSk+S2cYRv/o2qKqJSx1Sagzgt KnNstggRmlKyFIDH7vt+kaGe5YaKyBF0hE0Uzev2Sz6NOhr68xg8187aPD5J1bakxt3d oku6cHQC7yGq+iRVOvKlAljb7kYGt7mLqraM6C27HUMMETixQnImTYMo7nhb+uGZaROQ zm9kCBaTsfCxtmptbQhgGao53nLFvjoKq2gG8h844mgRNZUFLZm3zRrHtypzlH3T1zCL e1Jorg0QIMVTWpCMDQxIOVBEchZ11tYDCytNQ0VWmPleyrMEm2DdqJdnSDWORvF4AXjZ kwmw== X-Gm-Message-State: AN3rC/5LAn9r/3xLvxw7YrVEd2+zezXnXHv+rfRUZXmfWPIdMjIpBHim cHHZB8i+9J/9gDF/zVF8N/9zsfRBlpl0 X-Received: by 10.28.10.1 with SMTP id 1mr2449380wmk.98.1493913132038; Thu, 04 May 2017 08:52:12 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.157.38 with HTTP; Thu, 4 May 2017 08:52:11 -0700 (PDT) X-Originating-IP: [73.9.224.155] In-Reply-To: References: Date: Thu, 4 May 2017 10:52:11 -0500 X-Google-Sender-Auth: 9YRh3iStoQINWQhPtwS4O4kxlF8 Message-ID: To: Jesse Schalken Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Add is_vectorlike($array) function From: pollita@php.net (Sara Golemon) On Tue, May 2, 2017 at 4:13 AM, Jesse Schalken wrote: > The problem is that this function is O(n), but in PHP7 an array that is > vector-like is likely to be packed and without holes (HT_IS_PACKED(x) && > HT_IS_WITHOUT_HOLES(x)), in which case it is known to be vector-like > without needing to iterate over it, > Just want to underline the "is likely to be" part of this sentence. The implementation can't assume an array is not vector-like just because those checks fail. It's possible to manipulate an array into being vector-like, but not packed, or having holes. Not really commenting on the proposal yet, which I'm a big shoulder-shruggy about. Just highlighting the caveat for any eventual implementation. We can short-circuit the O(n) loop if it *is* packed/no-holes, but if not then we need to walk it to be certain. This is probably fine since this check is likely used in places where the array is expected to be vector like and non-vector should be a slow path anyway. -Sara