Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94736 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34545 invoked from network); 28 Jul 2016 08:59:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2016 08:59:22 -0000 Authentication-Results: pb1.pair.com header.from=ben.coutu@zeyos.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ben.coutu@zeyos.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zeyos.com designates 159.122.110.40 as permitted sender) X-PHP-List-Original-Sender: ben.coutu@zeyos.com X-Host-Fingerprint: 159.122.110.40 mx.zeyos.com Received: from [159.122.110.40] ([159.122.110.40:42907] helo=mx.zeyos.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/51-25564-969C9975 for ; Thu, 28 Jul 2016 04:59:21 -0400 Received: from mx.zeyos.com (mx.zeyos.com [127.0.0.1]) by mx.zeyos.com (Postfix) with ESMTP id 3870486 for ; Thu, 28 Jul 2016 11:00:41 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mx.zeyos.com Received: from mx.zeyos.com ([127.0.0.1]) by mx.zeyos.com (mx.zeyos.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TjEanN_wz22y for ; Thu, 28 Jul 2016 11:00:26 +0200 (CEST) Received: from 127.0.0.1 (9a.08.9905.ip4.static.sl-reverse.com [5.153.8.154]) by mx.zeyos.com (Postfix) with ESMTPSA id 3BEF182; Thu, 28 Jul 2016 11:00:24 +0200 (CEST) Date: Thu, 28 Jul 2016 10:59:00 +0200 To: Xinchen Hui Cc: PHP Internals MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20160728090041.3870486@mx.zeyos.com> Subject: [PHP-DEV] More packed hash optimizations in array.c From: ben.coutu@zeyos.com (Benjamin Coutu) Hello Xinchen,=0A=0AI have noticed two more cases where we could easily use= packed arrays.=0A=0A1. array_merge($packed1, $packed2, ...):=0A=0AIn the q= uite common case where all arguments are packed arrays, the resulting array= can also be a packed array (as per documentation: "if the input arrays [..= .] contain numeric keys, the later value will not overwrite the original va= lue, but will be appended"), thereby ensuring that packed arrays stay packe= d when appended to one another.=0AIn general we should try to preserve the = packed characteristics wherever possible.=0A=0A2. array_column($input, $col= umn_key, $index_key=3Dnull):=0A=0AFor the common case when $index_key=3Dnul= l, we can just create a packed array.=0AAlso (not related to packing), we c= ould pre-initialize the return_value array size with array_init_size() if, = and only if, $column_key=3Dnull.=0A=0APlease let me know your thoughts.=0A= =0AThanks,=0A=20 Ben =0A--=20 =0ABejamin Coutu ben.coutu@zeyos.com ZeyOS, Inc. http://www.zeyos.com