'From Squeak3.7beta of ''1 April 2004'' [latest update: #5972] on 19 July 2004 at 2:49:24 pm'! "Change Set: shortcutnewinitialize-md Date: 19 July 2004 Author: Marcus Denker We changed new: to call initialize some time ago. Back then Doug posted benchmarks that showed that we lost a little bit of performance. The question was if we couldn't speed the system back up with just a couple of shortcut implementations of new: in some often used classes. So, here are macrobenchmarks: current, new: calling initialize, no prim. #(7551 36755 0 6326 0 8823 8823) #(7484 36446 0 6451 0 8616 8616) #(7494 36717 0 6633 0 8981 8981) orig impl: #(7169 36148 0 6199 0 8800 8800) #(7277 36549 0 6233 0 8659 8659) #(7551 36144 0 6235 0 8880 8880) So we are a tiny bit slower. For Array new: I looked closer at the cost: (bench runs the block 5 seconds and shows invocations/sec) [1000 timesRepeat: [Array new:10]] bench Array: without: '1070.985802839432 per second.' with shortcut: ' '1725.0549890022 per second.'' So I did shortcuts for Array and String, and redid the macrobenchmarks: String/Array #(7216 35802 0 6140 0 8897 8897) #(7186 36142 0 6353 0 8590 8590) #(7245 36227 0 6216 0 8722 8722) So we are back at normal speed again. I don't think we should do to much of these shortcuts, just in cases were we see a problem. (e.g. classes that are instanciated often). These are real hacks anyway: As these are just inlinings (and copy-down-the-inheritens-chain) of self-sends, an optimizing VM could do this automatically... This changeset adds the two new: methods to Array and String. "! !Array class methodsFor: 'instance creation' stamp: 'md 7/19/2004 12:34'! new: sizeRequested "Answer an instance of this class with the number of indexable variables specified by the argument, sizeRequested. This is a shortcut (direct call of primitive, no #initialize, for performance" "This method runs primitively if successful" ^ self basicNew: sizeRequested "Exceptional conditions will be handled in basicNew:" ! ! !String class methodsFor: 'instance creation' stamp: 'md 7/19/2004 12:35'! new: sizeRequested "Answer an instance of this class with the number of indexable variables specified by the argument, sizeRequested. This is a shortcut (direct call of primitive, no #initialize, for performance" "This method runs primitively if successful" ^ self basicNew: sizeRequested "Exceptional conditions will be handled in basicNew:" ! !