in reply to Re: Re: Possible Memory Usage Issues
in thread Possible Memory Usage Issues
You have a simple space/time tradeoff to make, and you've indicated that the problem is space. If the overhead isn't significant for a slot in the object to hold a boolean to indicate whether the object is a leaf, then do it. But if you're still tight on space, trade that boolean for a function call. Sure, a function call takes "more CPU", but do you know whether that additional time is significant (or even measurable)? I'll bet that the overhead of
is barely measurable, and may be more than canceled out by not having to grow (at setup time) or access (at use time)the anonymous arrays that underly your objects.package Node; sub isLeaf { 0 } package Leaf; isLeaf { 1 }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Possible Memory Usage Issues
by abitkin (Monk) on Aug 07, 2002 at 16:45 UTC |