[Pharo-project] [update 1.2] #12161 - #12172

Igor Stasenko siguctua at gmail.com
Fri Oct 1 11:48:35 EDT 2010


Here what happens:

Original method WeakKeyDictionary>>finalizeValues

WeakKeyDictionary>>finalizeValues
	"Clear all associations with nil keys"
	array do:[:assoc|
	1 to: array size do:[:i | | assoc |
		assoc := array at: i.
		assoc ifNotNil:[
			assoc expire ifTrue:[
				expired := expired + 1.
				tally := tally - 1.
			].
		].
	].

And i noticed that after recompilation of this method, it starts
spending much more time to scan 14k entries:

[MCMethodDefinition cachedDefinitions finalizeValues ] timeToRun
 167

(my guess that this method was never recompiled with new Eliot's closures).

Now, if i change it to:
finalizeValues
	"Clear all associations with nil keys"
	1 to: array size do:[:i | | assoc |
		assoc := array at: i.
	array do:[:assoc|
		assoc ifNotNil:[
			assoc expire ifTrue:[
				expired := expired + 1.
				tally := tally - 1.
			].
		].
	].

so, #to:do: is inlined by compiler, then numbers is much better:

[MCMethodDefinition cachedDefinitions finalizeValues ] timeToRun
 4

Just try it yourself, if you not believe.

-- 
Best regards,
Igor Stasenko AKA sig.




More information about the Pharo-dev mailing list