Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61162 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84770 invoked from network); 12 Jul 2012 12:39:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2012 12:39:47 -0000 Authentication-Results: pb1.pair.com header.from=davidkmuir@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=davidkmuir@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.42 as permitted sender) X-PHP-List-Original-Sender: davidkmuir@gmail.com X-Host-Fingerprint: 209.85.160.42 mail-pb0-f42.google.com Received: from [209.85.160.42] ([209.85.160.42:42706] helo=mail-pb0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 04/87-46517-295CEFF4 for ; Thu, 12 Jul 2012 08:39:47 -0400 Received: by pbbrp12 with SMTP id rp12so4144273pbb.29 for ; Thu, 12 Jul 2012 05:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=Mm2qYQMS8TJGDXfzKjCsGoMpGGItmFRro++KWhEHIDk=; b=ZP0tUFJ06bStwQ0XxMJjgmtOst2e9JOQ5kHZ5gUhjpZ0zq797ZIxwwJddrt8hoFcBp SGUqOzkQustX4xCyQfme0fEsFji0GyC+1a5z46J6aPu6E/oO9mSIVlsmAiQTXdRY7Ek7 x7USFsDv75Pvi5iP9fVPdqfgHm/UmgxTlKJbrpU0evK8rT13IrLcc5Zroxpy5UMdi09n ouFX3tCq01BPyr97/687WJ7JxC+1kEoxT1BZi3qhmw3nqXhTeewY3BuX0i3HHgPqDT2B Ux57P0xpDOMYmnf/cUAWTQ9J7Q6AA+yLLN17Jdknj/6z4aEuxa3IUTEVbG6G6lqjhQVe Xivw== Received: by 10.68.233.132 with SMTP id tw4mr5288391pbc.61.1342096783741; Thu, 12 Jul 2012 05:39:43 -0700 (PDT) Received: from [192.168.0.14] (dsl-202-173-152-56.vic.westnet.com.au. [202.173.152.56]) by mx.google.com with ESMTPS id pc6sm3799667pbc.47.2012.07.12.05.39.41 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Jul 2012 05:39:43 -0700 (PDT) References: <4FFEB86D.3080302@quis.cx> In-Reply-To: <4FFEB86D.3080302@quis.cx> Mime-Version: 1.0 (1.0) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-ID: <43D27342-52D3-4D51-A574-F7A5075164C4@gmail.com> Cc: "internals@lists.php.net" X-Mailer: iPhone Mail (9B206) Date: Thu, 12 Jul 2012 22:39:38 +1000 To: Jille Timmermans Subject: Re: [PHP-DEV] array_shift() and reindexing From: davidkmuir@gmail.com (David Muir) What about replacing the existing array with array_slice? David On 12/07/2012, at 9:43 PM, Jille Timmermans wrote: > Hello, >=20 > array_shift() currently reindexes the array after shifting one element. Th= e reindexing has quite some impact on it's performance. I would like to sugg= est an extra parameter to array_shift() which can be used to prevent reindex= ing. >=20 > =46rom a few quick (and sloppy!) tests I get these results: > `reset($array); list($key, $value) =3D 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.= >=20 > If you agree this would be an useful addition I will create a patch. >=20 > -- Jille >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20