remember wrapped methods to speedup allInstances
authorClaus Gittinger <cg@exept.de>
Fri, 01 Jul 2011 10:52:35 +0200
changeset 2395 e9082ccc0d80
parent 2394 f867c637b7cb
child 2396 95b7dc0353f0
remember wrapped methods to speedup allInstances (req'd for single stepping)
WrappedMethod.st
--- a/WrappedMethod.st	Thu Jun 30 19:09:51 2011 +0200
+++ b/WrappedMethod.st	Fri Jul 01 10:52:35 2011 +0200
@@ -13,7 +13,7 @@
 
 Method variableSubclass:#WrappedMethod
 	instanceVariableNames:''
-	classVariableNames:''
+	classVariableNames:'AllWrappedMethods'
 	poolDictionaries:''
 	category:'Kernel-Methods'
 !
@@ -38,6 +38,10 @@
 "
     support for MessageTracer
 
+    notice: remembers wrappers in a weak classvar, because finding the wrapper for a
+    method is required for single stepping, and used to take a long time when using allInstances.
+    Therefore, wrappers are remembered.
+
     [author:]
         Claus Gittinger
 
@@ -46,6 +50,33 @@
 "
 ! !
 
+!WrappedMethod class methodsFor:'registration'!
+
+allInstancesDo:aBlock
+    AllWrappedMethods notNil ifTrue:[
+        AllWrappedMethods copy do:aBlock
+    ].
+
+    "Created: / 01-07-2011 / 09:45:29 / cg"
+!
+
+register:aWrappedMethod
+    AllWrappedMethods isNil ifTrue:[
+        AllWrappedMethods := WeakIdentitySet new.
+    ].
+    AllWrappedMethods add:aWrappedMethod
+
+    "Created: / 01-07-2011 / 09:44:56 / cg"
+!
+
+unregister:aWrappedMethod
+    AllWrappedMethods notNil ifTrue:[
+        AllWrappedMethods remove:aWrappedMethod ifAbsent:[]
+    ].
+
+    "Created: / 01-07-2011 / 10:03:55 / cg"
+! !
+
 !WrappedMethod methodsFor:'accessing'!
 
 basicLiterals
@@ -169,6 +200,20 @@
     ^ self originalMethod source
 ! !
 
+!WrappedMethod methodsFor:'misc'!
+
+register
+    self class register:self
+
+    "Created: / 01-07-2011 / 10:03:26 / cg"
+!
+
+unregister
+    self class unregister:self
+
+    "Created: / 01-07-2011 / 10:03:32 / cg"
+! !
+
 !WrappedMethod methodsFor:'queries'!
 
 argSignature
@@ -255,10 +300,6 @@
 
 !WrappedMethod class methodsFor:'documentation'!
 
-version
-    ^ '$Header: /cvs/stx/stx/libbasic3/WrappedMethod.st,v 1.28 2010-10-22 09:50:46 cg Exp $'
-!
-
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic3/WrappedMethod.st,v 1.28 2010-10-22 09:50:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic3/WrappedMethod.st,v 1.29 2011-07-01 08:52:35 cg Exp $'
 ! !