Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100969 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64180 invoked from network); 27 Oct 2017 16:10:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2017 16:10:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.172 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.223.172 mail-io0-f172.google.com Received: from [209.85.223.172] ([209.85.223.172:45605] helo=mail-io0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 16/DF-28573-26A53F95 for ; Fri, 27 Oct 2017 12:10:11 -0400 Received: by mail-io0-f172.google.com with SMTP id i38so13761865iod.2 for ; Fri, 27 Oct 2017 09:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oN+n8TXwfHD9gpbAx9pGS4bd+wAnMdKLsxYHf/DI4Ec=; b=II3aZ0tvcdmpna687DdLK4sKqkP/h7TDpdjxjksNAGPjIP11GcMZryYNVkw7Vulsao iXxaLw9WfYhwcmQ4Zqq57dMMmKwt9V7o3zNqgGyA4iijZmauckTQFHALs6PRcqp1ZMVz NlTDPE2qpLmS64bNAt8pwFTV7Kcn+KnBTgjUzHTdilSmHx/KllAr7+RHtZG6HRqOcX/z f9ziyzIUJsv4ahXZ3lvwodHKW3bWXPZR3oieBckcNlGQoyYu63Rc7Xvnhho6RLiiPAKC G8BDx5Y+oTMXmZgV7expAEaLatfalrMFhygREL1yi9cm4G6grZzgDOkoYsZeeWzKLk23 xzbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oN+n8TXwfHD9gpbAx9pGS4bd+wAnMdKLsxYHf/DI4Ec=; b=tWSDuhvNONTqq99yjb1K4ai5lmoQQspd/5aX+8j8N+Az/YGNjydlXah9uYPgt0j2C7 2fbcFOjDFq+PH5IqCt+SPijDDpKoNFS1MzfbkrHS5vJqxO04Lw6ODdjGHo5YzCL1u3ud PlFvc2UFsXNy6a73QklKR0qfJk55Wl4tKQBwhXqyGe1H/tmKGTHjuJk3+XzE5ZUr6ZWK uh/XYh56sSIga8s/XqQPXcNi630AErSFUiLS7KQEWYzDNPDhYXDByuZESZd6bdm8xWn7 B4LCpQtpEE+234XO+m1e9xc/hEqGvB3WhMWmTrjDk6WrXT+xXjfy59ATJoZDw9GWu3Gg 1gHA== X-Gm-Message-State: AMCzsaUdcRNt1HB3gEWggQ70H62FuDGlkWILJOw9s+naGyYphF73PuWm Eu/OiqU6T6bkx27yCJ2w6RrnY5ifOQkAet6z/Io= X-Google-Smtp-Source: ABhQp+RHUfWF0mDP0OXYIFEzkWFVKwgafN/YhV4O3swNVr/endkVJ63+NhWZhM/uXTT+Api65/4OkEYV8tGgF+FKA04= X-Received: by 10.36.192.133 with SMTP id u127mr1237636itf.27.1509120608331; Fri, 27 Oct 2017 09:10:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.35.78 with HTTP; Fri, 27 Oct 2017 09:10:07 -0700 (PDT) In-Reply-To: References: <20171027121225.2AAC95FB05@mx.zeyos.com> Date: Fri, 27 Oct 2017 18:10:07 +0200 Message-ID: To: Sara Golemon Cc: Benjamin Coutu , PHP Internals , Dmitry Stogov Content-Type: multipart/alternative; boundary="94eb2c05bb9ac86eab055c898573" Subject: Re: [PHP-DEV] Apply substr() optimization to array_slice() From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c05bb9ac86eab055c898573 Content-Type: text/plain; charset="UTF-8" On Fri, Oct 27, 2017 at 4:16 PM, Sara Golemon wrote: > On Fri, Oct 27, 2017 at 8:12 AM, Benjamin Coutu > wrote: > > Now, array_slice() could be optimized similarly, but currently > > (unless the resulting array is expected to be empty) we always > > create a new array no matter if we actually have to. > > > Pushed, with an additional escape hatch for vector-like arrays (which > are implicitly like preserve_keys). In the future though, please use > the PR process. Thanks. > Unfortunately these optimizations are subtly incorrect in the current form, because arrays have a bunch of additional hidden state. See https://bugs.php.net/bug.php?id=75433 for a (not yet fixed) issue that resulted from similar optimizations in 7.2. We'll have to review all the places where we apply optimizations like these and make sure that we're not introducing incorrect behavior wrt the next free element or internal array pointer. Nikita --94eb2c05bb9ac86eab055c898573--