[Pharo-project] Simple (but effective) Optimization of PackageOrganizer

Alexandre Bergel alexandre at bergel.eu
Fri Feb 26 12:58:14 EST 2010


issue #2085

Replace the method PackageOrganizer>>packageOfClass: aClass ifNone:  
errorBlock by
-=-=-=-=-=
packageOfClass: aClass ifNone: errorBlock
	| classCategory |
	classCategory := aClass category.
	packages at: classCategory ifPresent: [:v | ^ v].
	
	(classCategory includes: $-)
		ifTrue: [ packages at: (classCategory copyUpTo: $-) ifPresent: [:v |  
^ v] ].
	
	^ self packages detect: [:ea | ea includesClass: aClass] ifNone:  
errorBlock
-=-=-=-=-=

Before this enhancement:
[100 timesRepeat: [Object package]] timeToRun
=> 141

After the fix:
=> 2

Easy thing to do.

Cheers,
Alexandre
-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.







-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.









More information about the Pharo-dev mailing list