Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41849 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45432 invoked from network); 11 Nov 2008 00:28:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Nov 2008 00:28:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:47790] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D8/09-34173-6B1D8194 for ; Mon, 10 Nov 2008 19:28:38 -0500 Received: from [83.228.56.37] (port=3130 helo=pc) by host.fmethod.com with esmtpa (Exim 4.69) (envelope-from ) id 1Kzh7T-0007Z1-LL for internals@lists.php.net; Mon, 10 Nov 2008 18:28:36 -0600 Message-ID: To: References: <7e270cea0810191211w2cb77075y5e0ad78c2f7306f7@mail.gmail.com> <243C7392-C6A0-4EE8-8AAA-34964E78D453@tekrat.com> <4022974B-4A13-4AB0-A282-973503200406@tekrat.com> <38820B1D-6D5F-4B42-9FEE-0CDF23142A57@tekrat.com> <140FB8F69197441FAB5F45A64FDA946E@pc> <753B18C7-AC2F-4C96-B9CF-9FF5A042B96C@tekrat.com> Date: Tue, 11 Nov 2008 02:28:31 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] An optimization idea From: sv_forums@fmethod.com ("Stan Vassilev | FM") > This wouldn't really help with the case here of "if ($array1 == > $array2)..." though right? (not to say it's not good, just making sure I > understand ;-) ). Yes I'm talking about speeding up scenarios full of hash lookups in general. > > It sounds like this would only work if the array contents where static > though, as you're mapping a constant string to the contents of the hash > (or did I misunderstand and you'd be mapping string const. values to hash > IDs?). My point is, replacing this process: $a['foo'] or $a->foo -> compute hash of 'foo' -> find item for hash 'foo' -> many items? -> resolve conflict -> return item With this process: $a[% string_literal_id_5 %] -> lookup item key 5 for array -> return item Notice we skipped hash generation, and conflict resolution altogether. We only have the lookup for the integer id. If some additional work is done, even this lookup can be eliminated and make this an O(1) process. If instead the coder used variable: $a[$bar] or $a->$foo (var array lookup and var var object lookup), then this optimization can't kick in, and the existing algorithm will be used. However "static" access is the predominant usage, especially for objects, but also for arrays, so this should have significant impact. Regards, Stan Vassilev