Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29386 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47050 invoked by uid 1010); 9 May 2007 22:46:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47035 invoked from network); 9 May 2007 22:46:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 May 2007 22:46:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=maurice@phorum.org; spf=fail; sender-id=fail Authentication-Results: pb1.pair.com header.from=maurice@phorum.org; sender-id=fail Received-SPF: fail (pb1.pair.com: domain phorum.org does not designate 217.149.192.18 as permitted sender) X-PHP-List-Original-Sender: maurice@phorum.org X-Host-Fingerprint: 217.149.192.18 smtp20.nijmegen.internl.net Solaris 10 (beta) Received: from [217.149.192.18] ([217.149.192.18:35265] helo=smtp20.nijmegen.internl.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/48-60325-43F42464 for ; Wed, 09 May 2007 18:46:14 -0400 Received: from [192.168.2.151] by smtp20.nijmegen.internl.net via 78-198.bbned.dsl.internl.net [217.149.198.78] with ESMTP id l49Mk6Jh000907 (8.13.8/2.04); Thu, 10 May 2007 00:46:07 +0200 (CEST) Message-ID: <46424F2E.5070701@phorum.org> Date: Thu, 10 May 2007 00:46:06 +0200 Reply-To: maurice@phorum.org Organization: Phorum.org User-Agent: Thunderbird 1.5.0.10 (X11/20070403) MIME-Version: 1.0 To: Derick Rethans CC: michael.walter@gmail.com, RQuadling@googlemail.com, brianm@dealnews.com, internals@lists.php.net References: <4641D92C.4050208@dealnews.com> <10845a340705090743v6aba7896y45b9f7d60a4e77ba@mail.gmail.com> <4641E3DD.8040807@phorum.org> <877e9a170705090913i320359cag81b0a3bf203e2c86@mail.gmail.com> <464202D9.8080509@phorum.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Tree sort in C From: maurice@phorum.org (Maurice Makaay) Hi, > That is very peculiar... it should never be slower than an > implementation in PHP - unless your algorithm isn't optimal. > Depends on your definition of "optimal". In setting up the structures, I have a linear search going to find the node for a parent. That's why it gets slower for (very) large quantities of nodes. It would be easy enough to introduce a hashing table there for quick lookups, but of course at the cost of extra memory. I have looked at my forums (since like Brian wrote: the code that we have is targeted at Phorum's message trees) and there I need sorting for up to a several thousand nodes at most. The large majority of the sorts are several hundreds at most. So this code needs no further optimization there. If this would go in the PHP internals, then I asume the function code would probably be balancing between fast processing and little memory use. Regards, Maurice Makaay Phorum.org