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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php