Hello,
While working on hashing, I wrote this bit of new code to speed up some
of the tools. I hope I didn't make a mistake... it seems to me it
should work fine.
Enjoy!
Andres.
'From Pharo1.0rc1 of 19 October 2009 [Latest update: #10491] on 1 November 2009 at 4:30:53 pm'!
"Change Set: OBRescueFilter-Speedup
Date: 1 November 2009
Author: SqR
Avoid linear search in OBRescueFilter>>cache:for: and O2RescueFilter>>cache:for:. The speedup is most noticeable when e.g.: checking senders of #closeTo: and selecting something like CompiledMethod>>="!
!O2RescueFilter methodsFor: 'filtering' stamp: 'SqR 11/1/2009 16:30'!
cache: aCollection for: aNode
| cached missing inclusionSet |
cached _ cache at: aNode ifAbsent: [^ self initCache: aCollection for: aNode].
cache at: aNode put: aCollection.
missing _ rescued at: aNode ifAbsent: [Set new].
inclusionSet := aCollection asSet.
missing removeAllSuchThat: [:ea | inclusionSet includes: ea].
cached do: [:ea | (inclusionSet includes: ea) ifFalse: [missing add: ea]].
missing isEmpty ifFalse: [rescued at: aNode put: missing].
^ missing asArray! !
!OBRescueFilter methodsFor: 'filtering' stamp: 'SqR 11/1/2009 16:27'!
cache: aCollection for: aNode
| cached missing inclusionSet |
cached := cache
at: aNode
ifAbsent:
[ ^ self
initCache: aCollection
for: aNode ].
cache
at: aNode
put: aCollection.
missing := rescued
at: aNode
ifAbsent: [ Set new ].
inclusionSet := aCollection asSet.
missing removeAllSuchThat: [ :ea | inclusionSet includes: ea ].
cached do: [ :ea | (inclusionSet includes: ea) ifFalse: [ missing add: ea ] ].
missing isEmpty ifFalse:
[ rescued
at: aNode
put: missing ].
^ missing asArray! !
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project