speedup #who (guess className from sourceFileName)
authorClaus Gittinger <cg@exept.de>
Fri, 10 Mar 2000 19:12:34 +0100
changeset 5294 f2d689cf7be4
parent 5293 e329b1ad8fe9
child 5295 f144309dab04
speedup #who (guess className from sourceFileName)
Method.st
--- a/Method.st	Fri Mar 03 16:40:11 2000 +0100
+++ b/Method.st	Fri Mar 10 19:12:34 2000 +0100
@@ -2188,10 +2188,34 @@
      Q2: if so, what about the bad guy then, who copies methods around to
          other classes ?"
 
-    |classes cls sel|
+    |classes cls sel fn clsName|
 
     "
-     very first, look in the class we found something the last time
+     speedup kludge: if my sourceFileName is valid,
+     extract the className from it and try that class first.
+    "
+    (fn := self sourceFilename) notNil ifTrue:[
+        clsName := fn asFilename withoutSuffix name.
+        clsName := clsName asSymbolIfInterned.
+        clsName notNil ifTrue:[
+            cls := Smalltalk at:clsName ifAbsent:nil.
+            cls notNil ifTrue:[
+                sel := cls selectorAtMethod:self.
+                sel notNil ifTrue:[
+                    ^ MethodWhoInfo class:cls selector:sel
+                ].
+
+                cls := cls class.
+                sel := cls selectorAtMethod:self.
+                sel notNil ifTrue:[
+                    ^ MethodWhoInfo class:cls selector:sel
+                ].
+            ]
+        ].
+    ].
+
+    "
+     then, look in the class we found something the last time
      this may often give a hit, when asking who repeatingly for
      a context chain. (keep last by its name, to not keep classes from
      being garbage collected)
@@ -2484,6 +2508,6 @@
 !Method class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.184 2000-02-29 18:09:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Method.st,v 1.185 2000-03-10 18:12:34 cg Exp $'
 ! !
 Method initialize!