Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119854 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 18306 invoked from network); 10 Apr 2023 12:45:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Apr 2023 12:45:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 042A11804C6 for ; Mon, 10 Apr 2023 05:45:43 -0700 (PDT) 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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 10 Apr 2023 05:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1681130741; bh=Qy3KCAtgazFEKofSK/R06PJBZ9SN6rUL76A2Zr14R+c=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=PExRK3eyf/p8NLXrvnirjsIX1FihBPR35IOu3FRFZeZVBPUKR7xmp6gYUDbyGiQIS 1H69uwcHHHPqW6/E6lc0dOuwqo2kSyyP0f39lFvtD7yxtCJIWZtHgX571of2bjZYBl WgoGp6g9mYBNWSTLnYiB2vxde/D5oJ5ZQ3mlpRzCG3avIago5XvDRT/xH5aSZStq12 OUsVz/zlpUW/NXB4zQ3FGQwo6SjcThLxJTRw1mUO2uaW7ghdGzZ4/TVyy0BNkkait7 2Bo0k1D+nKg9gMupi0TvdIbMebdA40KER73wnUc1bueQx8yeEthH46A8f3KcQsZLPK lIQjP+b366r7Q== Message-ID: <8c615ee5-a1a1-d760-ca92-65f0fd4c5b79@bastelstu.be> Date: Mon, 10 Apr 2023 14:45:41 +0200 MIME-Version: 1.0 Content-Language: en-US To: Niels Dossche , "Vorisek, Michael" , "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Array spread append From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) Hi On 4/8/23 22:17, Niels Dossche wrote: > I think this could be made more generic, and be cleaned up. > But I don't know if something like this is desired in PHP. Yes, please. I believe that “performance” should not influence API design if it can be avoided. Instead the heavy lifting of optimization should be done by the engine (see also: https://externals.io/message/118896#118921). The suggested optimization of "the input is overwritten with the output" would then also allow to avoid introducing reference parameters just for optimization purposes. The sort() family comes to my mind and also the shuffle() function. Randomizer::shuffleArray() already returns a copy and thus would benefit from the proposed optimization for $a = $r->shuffleArray($a). Best regards Tim Düsterhus