Think about Loose Coupling | |
PerlMonks |
Re: inline perl and recursionby jackdied (Monk) |
on Aug 07, 2002 at 20:38 UTC ( [id://188451]=note: print w/replies, xml ) | Need Help?? |
Inline::C would likely be more complicated that it is worth.
You may be able to squeeze some more uumph out of the perl version, as the poster above pointed out. If you are recalculating this more than once (it doesn't look like you are) you could have the children notify the parent when their own depth changes. This way you wouldn't have to recalc the whole tree if just a couple changed. If you are only doing this once, you could try some other optimizations. Keep two lists of children in the parent, one for object type #1's (which have variable depth) and the main list which has all objects. If the max depth of the #1s list is greater than one, just use that. If there are alot of #2 nodes, you save the function call overhead. Not great OO, but if you need the speed ... You could try something like To speed up the inner loop as well. That might have a touch of python syntax in it, but it is close to what you want.
In Section
Seekers of Perl Wisdom
|
|