Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:47348 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56039 invoked from network); 16 Mar 2010 22:28:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2010 22:28:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=hannes.magnusson@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=hannes.magnusson@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: hannes.magnusson@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-ww0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:62641] helo=mail-ww0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/FA-15129-42600AB4 for ; Tue, 16 Mar 2010 17:28:52 -0500 Received: by wwd20 with SMTP id 20so353166wwd.29 for ; Tue, 16 Mar 2010 15:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=XhtC/kOlRckeOkrsLvOTa5DjFYCg/t41vrbP+Ins9J4=; b=o4F4jSasyRXnC8XRvzXXilJxJVhpvKyn4w59ttL14g2EVTIzD32UrjkMryZsPCYmFZ y/WaD46Tk5mUF+fknkGkZSK+Mf4x7P/oAQH2CGeSK8mplofTuvLsW2CUNrz8+/GSiles 91zw+LO6Elgd3n7gfFBbOBAgomgUtlLJDGM6Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Zu4mIVM0ZaRHxCoUAapAe0eKLyCy9TGLKn6SLBZc9cexXhhvpZp8cW/XWJlDNAsvK3 Y2jL7u8ATXuMDdu000zT8MmfjfKzgzw9w4zuJM8LzeI1Bti8TkxmzYJ7prOMP5wufEZi RQLkQpap6/hSDgKti0CWHyD4eh1GBi0LpxPBY= MIME-Version: 1.0 Received: by 10.216.173.85 with SMTP id u63mr85764wel.279.1268778527664; Tue, 16 Mar 2010 15:28:47 -0700 (PDT) In-Reply-To: <8cf711461003160912m6ab0ecf4ga08ed7dc82375073@mail.gmail.com> References: <6E76B52E-7543-4F09-A948-A7910513B548@gmail.com> <4B9F91E9.1000100@cschneid.com> <8cf711461003160912m6ab0ecf4ga08ed7dc82375073@mail.gmail.com> Date: Tue, 16 Mar 2010 23:28:47 +0100 Message-ID: <7f3ed2c31003161528m4a31845fjefd4a7696baaab51@mail.gmail.com> To: Mikko Koppanen Cc: Christian Schneider , Felix De Vliegher , PHP internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: array_seek function From: hannes.magnusson@gmail.com (Hannes Magnusson) On Tue, Mar 16, 2010 at 17:12, Mikko Koppanen wrote: > On Tue, Mar 16, 2010 at 2:12 PM, Christian Schneider > wrote >> I thinks the user space implementation >> >> function array_seek($array, $pos) >> { >> =A0 =A0 =A0 =A0$a =3D array_values($array); >> =A0 =A0 =A0 =A0return $a[$pos]; >> } >> >> is simple enough to not add a native function for this. >> >> It might not be the most efficient way to do it but I doubt that it is >> something done frequently enough to justify another native function. > slightly modified version of the original patch > http://valokuva.org/~mikko/array_seek.patch.txt. The difference to the I once porpoised similar patch to in_array, where it didn't reset the position after finding the "found element". In applications like PhD, this is extremely useful and safes us at least 10% overhead (at the time I benchmarked it with my patch to in_array()). I think we wound up with something like: while (list($key, $val) =3D each($array)) { if ($key =3D=3D "foobar") { break; } } next($array); $current_index =3D current($array); To get the _next_ value after the known "currently known value (or key)". In an application like PhD (which already brought 24hours (DSSSL 24hours, xsltproc two formats compile time to) down to ~3-4minutes (3-5formats), 10% of _language_ overhead is extremely important, so I am all for a function that can do this (our/my goal is max 1minute... - sorry, HD read/write is still extremely expensive :(, it simply cant get faster then that afaict - if you have an idea; GSOC is open for experiments.. :D). -Hannes