Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119116 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54553 invoked from network); 13 Dec 2022 12:26:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Dec 2022 12:26:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C7D911804A7 for ; Tue, 13 Dec 2022 04:26:26 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oa1-f47.google.com (mail-oa1-f47.google.com [209.85.160.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 13 Dec 2022 04:26:26 -0800 (PST) Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-1322d768ba7so12285871fac.5 for ; Tue, 13 Dec 2022 04:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=I1lTkshwUdkQoZABIX8RJKqSUaDw/yQRYGcjIxQV5aM=; b=eL7Iv4lystTjhUpZtuC72T2Krdfaj7PUFeX2Ax3q4keTBqqXoIUZWUokju2TlGrjED 4SeGETq9AXDHv+RHPXBvg5xCl8493qAtEb7LBOIGrLfYPzEa6AU1RLmhpvW2K5PQGSjO vDGtLdAGqfvbZSK+0Baz+aeU8qRUAGkGO1DfpKJOBuqzJufttsULAmTyZZjeq6g4GPJS j7P0Gu5vu2M0C3tn0ajuPehbyE8PR/5pld904GKBHXuRJVFhf9vU1T45O5xglp1pZalW gb0jDrqKwrBlqvWzM/VHKQ7A00krwx7LzDEPWYBKpfxsajM79Zry1w7vQglHYYJvEdK0 qL5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I1lTkshwUdkQoZABIX8RJKqSUaDw/yQRYGcjIxQV5aM=; b=udWQX+NrZLryKr54V4XEigOW6VnDxMy2uNZj6vL6Knc84GWCrRqRsvf7Ez/2B/pEjG uOztSxUrJbalKXyiPhMrefkiQ8d7naGHvm8EMdTP1E6ZqrSh2gSDXS/xgSWRTkjsZXyp O5xR26LSpXHNvfvD7y5+y3k6qzcn2X0Fn/j0FPZrxBjXUPRK61JmuhRgrQ9mN6CChTmI MW2+L09Fp7zRrgvxr4OlFVxgrDCWhv2jYbRHJQoDAK+EzQ908hD0hvDKe5rcUCB5gbYw 5Wn83qHyv2ZJ884i4bRhIvUXYr1FTAXmvyif59rS/eZvXob9Nwi6TzH50CjvSDpCMXfM ODlA== X-Gm-Message-State: ANoB5plzFCD2V/T+ps2nGAqDKubRJYecNAyo6p+stiVEmNVppsGRUzn+ 6eRNWDr2X5b/4hikjWt8qgpdksmPQVCumN1wz+UZVx/pLPIMQHfS X-Google-Smtp-Source: AA0mqf6d6MBUG33auNXuFzc9Y08OMLFwZfEk4CGa8qjj8bWEynEfptfJE8WWv72iPMknRJ407t3NaqrAp2UulU8W254= X-Received: by 2002:a05:6870:5785:b0:13d:51fe:3404 with SMTP id i5-20020a056870578500b0013d51fe3404mr193134oap.183.1670934385718; Tue, 13 Dec 2022 04:26:25 -0800 (PST) MIME-Version: 1.0 References: <5fe0d8a9-d305-9c9d-ca36-1ca30de87b78@cubiclesoft.com> <156fca4c-dd75-af1d-ebb8-b9783b8f0b5a@gmx.net> In-Reply-To: <156fca4c-dd75-af1d-ebb8-b9783b8f0b5a@gmx.net> Date: Tue, 13 Dec 2022 13:26:14 +0100 Message-ID: To: Andreas Leathley Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Revisiting RFC: Engine Warnings -- Undefined array index From: landers.robert@gmail.com (Robert Landers) On Tue, Dec 13, 2022 at 11:16 AM Andreas Leathley wrote: > > On 13.12.22 11:01, Robert Landers wrote: > > intended: ($a['foo'] ?? null) || ($a['bar'] ?? null) > > Further, writing code like this increases the number of opcodes needed > > to perform relatively simple logic by ~150%, increasing end-user > > latency and spending CPU cycles somewhat needlessly. > I think it is quite the opposite: calling the error handler because of > E_NOTICE (or now E_WARNING) is quite the additional overhead, and if > projects just ignore E_NOTICE their applications will be slowed down > because of that, while fixing the code will avoid the error handler > altogether. Just because something is longer to write in a programming > language also does not make it necessarily slower. But if you have any > actual measurements why using the null coalescing operator would slow > down code in general that would be something useful to share. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > Ah, that's a good point. I ran some tests and was surprised that it was slower due to needing to call the error handler. I even disabled E_WARNING in my php.ini to see if that made a difference (it did, but still not the same quite as fast as using null coalesce). Results are here: https://gist.github.com/withinboredom/bd7276b7703663c26c12a18820747bcb Interestingly the null coalesces used more memory. That surprised me and was unexpected. Apparently using coalesce requires some temporary variables to work. Perhaps there would be a benefit for a FETCH_DIM_IS_COALESCE opcode?