Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61161 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69217 invoked from network); 12 Jul 2012 11:43:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2012 11:43:54 -0000 Authentication-Results: pb1.pair.com header.from=jille@quis.cx; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jille@quis.cx; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain quis.cx from 82.94.237.14 cause and error) X-PHP-List-Original-Sender: jille@quis.cx X-Host-Fingerprint: 82.94.237.14 mulgore.hexon-is.nl Received: from [82.94.237.14] ([82.94.237.14:60126] helo=mulgore.hexon-is.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/34-46517-678BEFF4 for ; Thu, 12 Jul 2012 07:43:52 -0400 Received: from adidas.hexon-nijmegen.nl (gw.hexon-nijmegen.nl [82.93.241.107]) by mulgore.hexon-is.nl (8.14.3/8.14.3) with ESMTP id q6CBhffn027898 for ; Thu, 12 Jul 2012 13:43:42 +0200 Received: from [10.0.0.137] (pcjille.hexon-nijmegen.nl [10.0.0.137]) by adidas.hexon-nijmegen.nl (8.14.3/8.14.3) with ESMTP id q6CBhfkc011344 for ; Thu, 12 Jul 2012 13:43:41 +0200 Message-ID: <4FFEB86D.3080302@quis.cx> Date: Thu, 12 Jul 2012 13:43:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Hexon-MailScanner-Information: Please contact the ISP for more information X-Hexon-MailScanner-ID: q6CBhffn027898 X-Hexon-MailScanner: Found to be clean X-Hexon-MailScanner-From: jille@quis.cx X-Hexon-MailScanner-Watermark: 1342698223.40203@6zVsqYV4tYtS7ftXKYdCQw Subject: array_shift() and reindexing From: jille@quis.cx (Jille Timmermans) Hello, array_shift() currently reindexes the array after shifting one element. The reindexing has quite some impact on it's performance. I would like to suggest an extra parameter to array_shift() which can be used to prevent reindexing. From a few quick (and sloppy!) tests I get these results: `reset($array); list($key, $value) = each($array); unset($array[$key]);` is ~50-150 times faster than array_shift(). Calling array_reverse() and using array_pop() is ~2000-5000 times faster. If you agree this would be an useful addition I will create a patch. -- Jille