DoIts and selector removal
Stephen Pair
spair at advantive.com
Sun Dec 9 20:12:18 UTC 2001
I've noticed that doits appear to be taking a long time to run (I
recently had a process that seemed to take much longer than it
should...it involved a number of calls to Compiler>>evaluate:). After
investigating, I realized that every DoIt invokes a #become: operation
to atomically swap out the method dictionary with a copy that has the
#DoIt method removed. Ah...
So, the question: Is this really necessary? Can't we just store the
new method dictionary in the methodDict slot of the class?
Can we safely change the following method:
Behavior>>removeSelectorSimply: selector
"Assuming that the argument, selector (a Symbol), is a message
selector
in my method dictionary, remove it and its method."
| oldMethod |
oldMethod _ self methodDict at: selector ifAbsent: [^ self].
self methodDict removeKey: selector.
"Now flush Squeak's method cache, either by selector or by
method"
oldMethod flushCache.
selector flushCache.
To be:
Behavior>>removeSelectorSimply: selector
"Assuming that the argument, selector (a Symbol), is a message
selector
in my method dictionary, remove it and its method."
| oldMethod newDict |
oldMethod _ self methodDict at: selector ifAbsent: [^ self].
newDict _ self methodDict removeKeyNoBecome: selector.
methodDict _ newDict.
"Now flush Squeak's method cache, either by selector or by
method"
oldMethod flushCache.
selector flushCache.
This should also make fileIns a bit faster, as well as removing methods
in general.
- Stephen
More information about the Squeak-dev
mailing list
|