'From Squeak3.1alpha of 28 February 2001 [latest update: #4003] on 11 May 2001 at ?'! "Change Set: StringMorphOptimize Date: 11 May 2001 Author: Ned Konz This speeds up browsers and menu display by deferring the setting of StringMorph to its default string as long as possible. In most cases, StringMorph instances are set to something other than 'String Morph'. There were also two duplicate 'changed' calls in StringMorph every time that contents: was called. This fixes this to call changed once per contents: call: contents: fitContents extent changed These changes resulted in a speedup of 28% on popping up the alphabeticalMorphMenu, as measured by: wm _ TheWorldMenu someInstance. ((1 to: 20) collect: [ :i | Smalltalk garbageCollectMost. Time millisecondsToRun: [ wm alphabeticalMorphMenu ]]) average asFloat "! !StringMorph methodsFor: 'initialization' stamp: 'nk 3/16/2001 23:35'! initialize super initialize. color _ Color black. font _ nil. emphasis _ 0. hasFocus _ false. ! ! !StringMorph methodsFor: 'accessing' stamp: 'nk 3/15/2001 12:22'! contents: newContents newContents isText ifTrue: [emphasis _ newContents emphasisAt: 1. contents _ newContents string] ifFalse: [contents = newContents ifTrue: [^ self]. "no substantive change" contents _ newContents]. self fitContents. ! ! !StringMorph methodsFor: 'accessing' stamp: 'nk 5/11/2001 09:26'! fitContents | scanner | scanner _ DisplayScanner quickPrintOn: Display box: Display boundingBox font: self fontToUse. self extent: (((scanner stringWidth: contents) max: self minimumWidth) @ scanner lineHeight). ! ! !StringMorph methodsFor: 'layout' stamp: 'nk 5/11/2001 09:33'! fullBounds self contents ifNil: [ self contents: 'String Morph' ]. ^super fullBounds! !