On Fri, Dec 18, 2009 at 6:04 PM, Martin McClure <martin@hand2mouse.com>wrote:
Stan Shepherd wrote:
Pharo image: Pharo | Pharo-core PharoCore1.0rc1 Latest update: #10502 VM: unix - i686 - linux-gnu - Pharo0.1 of 16 May 2008 [latest update: #10074]
Steps to reproduce: 1.[Object allSubInstances size inspect] timeToRun 375479 (6 minutes)
with fix [Object allSubInstances size inspect] timeToRun 22335 (22 seconds)
Attached treats Object as a special case, and takes advantage of primitive in SystemNavigation>>allObjectsDo:
It looks like with this change, Object allSubInstances would return instances of classes that do not inherit from Object, for instance objects that inherit from ProtoObject.
Perhaps the special case should go on ProtoObject? Or a test could be made of how many subclasses a class has, and if it's over some arbitrary number just iterate through all objects and test each one for isKindOf:? Don't know how fast that would be, maybe it's not faster. But probably slow is preferable to incorrect. If you just want "all objects" and don't care about their class then you can always use SystemNavigation>>allObjectsDo: rather than allSubInstances.
+1. I don't think there's any justification for this hack. It's possible to have another root to the hierarchy apart from ProtoObject. Further, a bit weak, but allSubInstancesDo: has ordering properties; it will evaluate the block with all instances of a class followed by all instances of another and so on; it will visit all instances of any superclass before it visits any instances of subclasses, and that could be useful. If you want to use allObjectsDo: use it. Of course allSubInstancesDo: is slow; it makes as many scans of the system as there are classes (Metaclass avoids the scan by evaluating with soleInstance). But that's not a justification for special-casing one use of it to a freely accessible but different alternative.
Regards,
-Martin
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project