On Fri, 19 Feb 2010, Henrik Johansen wrote:
Well, ugly was a strong word. Reusing less, aka. shorter is a better choice, I guess.
I think the difference is 3 lines for the 4 methods.
Cheers, Henry
PS. In VisualWorks, the two perform equally. *Wishing for a Cog VM to test on* :)
There's no inlining VM available ATM (besides SqueakJ, but that can't run current images) and noone knows when one will be. And even though I didn't try it, I expect that "inlining by hand" saves time and memory.
PPS. For those interested, the alternative, faster version Levente made can be found at http://paste.lisp.org/display/93130
Here is a working example (the linked version has a bug): BlockClosure >> cull: argument1 cull: argument2 numArgs = 2 ifTrue: [ ^self value: argument1 value: argument2 ]. numArgs = 1 ifTrue: [ ^self value: argument1 ]. ^self value (For #cull:cull:cull: the difference is ~1.7x if the block has 0 or 1 argument, and ~1.3x if it has 2 arguments) Levente
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project