tuning
authorClaus Gittinger <cg@exept.de>
Tue, 03 Aug 1999 14:56:24 +0200
changeset 4514 abc3f0992176
parent 4513 b16770982c62
child 4515 1310283ed45d
tuning
QuerySig.st
QuerySignal.st
--- a/QuerySig.st	Tue Aug 03 14:55:02 1999 +0200
+++ b/QuerySig.st	Tue Aug 03 14:56:24 1999 +0200
@@ -288,6 +288,10 @@
     hasDefault := true.
 
     "/ avoid creating a fullBlock, in the most common cases
+    "/ therefore, do not replace the code below by
+    "/     handler := [:ex | ex proceedWith:someValue]
+    "/ although it is semantically equivalent.
+
     someValue == true ifTrue:[
         handler := [:ex | ex proceedWith:true]
     ] ifFalse:[
@@ -362,7 +366,7 @@
     |arg|
 
     theContext selector == #'answer:do:' ifTrue:[
-        (self accepts:signal) ifTrue:[
+        (self == signal or:[self accepts:signal]) ifTrue:[
             arg := theContext argAt:1.
             ^ [:ex| ex proceedWith:arg].
         ]
@@ -389,32 +393,7 @@
      Invoking the handler is exactly the functionality of Signal>>raiseRequest,
      but we can do it faster here."
 
-    |con s|
-
-    con := Context findFirstSpecialHandle:true raise:false.
-    [con notNil] whileTrue:[
-        (con selector == #answer:do:) ifFalse:[
-            ^ super raiseRequest
-        ].
-        (s := con receiver) == self ifTrue:[
-            ^ con argAt:1
-        ].
-        (s accepts:self) ifTrue:[
-            ^ super raiseRequest
-        ].
-        con := con findSpecialHandle:true raise:false.
-    ].
-    "/ no handler found - return the default value
-    hasDefault == true ifTrue:[
-        ^ defaultAnswer
-    ].
-    handlerBlock isNil ifTrue:[
-        ^ nil
-    ].
-    ^ super raiseRequest
-
-    "Modified: / 15.6.1998 / 21:27:37 / cg"
-    "Modified: / 25.7.1999 / 23:35:11 / stefan"
+    ^ self raiseRequest
 !
 
 raise
@@ -422,21 +401,66 @@
      so they should be raised with #query or #raiseRequest"
 
     self obsoleteMethodWarning:'use #query or #raiseRequest'.    
-    ^ self query
+    ^ self raiseRequest
 
     "Modified: / 18.3.1999 / 18:33:57 / stefan"
 !
 
 raiseRequest
-    "redefined to use #query"
+    "raise the query - return the handlers value, or the default
+     value, if there is no handler.
+     Invoking the handler is exactly the functionality of Signal>>raiseRequest,
+     but we can do it faster here, by avoiding the creation of a full-blown
+     exception object."
+
+    |con s|
 
-    ^ self query
+    con := Context findFirstSpecialHandle:true raise:false.
+    [con notNil] whileTrue:[
+        (s := con selector) == #'answer:do:' ifTrue:[
+            (s := con receiver) == self ifTrue:[
+"/ '0' printCR.
+                ^ con argAt:1
+            ].
+            (s accepts:self) ifTrue:[
+"/ '*2' printCR.
+                ^ super raiseRequest
+            ].
+        ] ifFalse:[
+            s == #'handle:do:' ifFalse:[
+"/ '*1a ' print. con printCR.
+                ^ super raiseRequest
+            ].
+            (s := con receiver) == self ifTrue:[
+"/ '*1b ' print. con printCR.
+                ^ super raiseRequest
+            ].
+            (s accepts:self) ifTrue:[
+"/ '*1c ' print. con printCR.
+                ^ super raiseRequest
+            ]
+        ].
+        con := con findSpecialHandle:true raise:false.
+    ].
 
-    "Created: / 2.3.1998 / 10:41:03 / stefan"
+    "/ no handler found - return the default value
+    hasDefault == true ifTrue:[
+"/ '3 ' print. self print. ' default: ' print. defaultAnswer printCR.
+        ^ defaultAnswer
+    ].
+    handlerBlock isNil ifTrue:[
+"/ '4 ' print. self print. ' nil: ' printCR.
+        ^ nil
+    ].
+"/ '*5 ' print. self print. ' handlerBlock' printCR.
+    ^ super raiseRequest
+
+    "Modified: / 15.6.1998 / 21:27:37 / cg"
+    "Modified: / 25.7.1999 / 23:35:11 / stefan"
 ! !
 
 !QuerySignal class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/QuerySig.st,v 1.30 1999-08-02 15:03:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/QuerySig.st,v 1.31 1999-08-03 12:56:24 cg Exp $'
 ! !
--- a/QuerySignal.st	Tue Aug 03 14:55:02 1999 +0200
+++ b/QuerySignal.st	Tue Aug 03 14:56:24 1999 +0200
@@ -288,6 +288,10 @@
     hasDefault := true.
 
     "/ avoid creating a fullBlock, in the most common cases
+    "/ therefore, do not replace the code below by
+    "/     handler := [:ex | ex proceedWith:someValue]
+    "/ although it is semantically equivalent.
+
     someValue == true ifTrue:[
         handler := [:ex | ex proceedWith:true]
     ] ifFalse:[
@@ -362,7 +366,7 @@
     |arg|
 
     theContext selector == #'answer:do:' ifTrue:[
-        (self accepts:signal) ifTrue:[
+        (self == signal or:[self accepts:signal]) ifTrue:[
             arg := theContext argAt:1.
             ^ [:ex| ex proceedWith:arg].
         ]
@@ -389,32 +393,7 @@
      Invoking the handler is exactly the functionality of Signal>>raiseRequest,
      but we can do it faster here."
 
-    |con s|
-
-    con := Context findFirstSpecialHandle:true raise:false.
-    [con notNil] whileTrue:[
-        (con selector == #answer:do:) ifFalse:[
-            ^ super raiseRequest
-        ].
-        (s := con receiver) == self ifTrue:[
-            ^ con argAt:1
-        ].
-        (s accepts:self) ifTrue:[
-            ^ super raiseRequest
-        ].
-        con := con findSpecialHandle:true raise:false.
-    ].
-    "/ no handler found - return the default value
-    hasDefault == true ifTrue:[
-        ^ defaultAnswer
-    ].
-    handlerBlock isNil ifTrue:[
-        ^ nil
-    ].
-    ^ super raiseRequest
-
-    "Modified: / 15.6.1998 / 21:27:37 / cg"
-    "Modified: / 25.7.1999 / 23:35:11 / stefan"
+    ^ self raiseRequest
 !
 
 raise
@@ -422,21 +401,66 @@
      so they should be raised with #query or #raiseRequest"
 
     self obsoleteMethodWarning:'use #query or #raiseRequest'.    
-    ^ self query
+    ^ self raiseRequest
 
     "Modified: / 18.3.1999 / 18:33:57 / stefan"
 !
 
 raiseRequest
-    "redefined to use #query"
+    "raise the query - return the handlers value, or the default
+     value, if there is no handler.
+     Invoking the handler is exactly the functionality of Signal>>raiseRequest,
+     but we can do it faster here, by avoiding the creation of a full-blown
+     exception object."
+
+    |con s|
 
-    ^ self query
+    con := Context findFirstSpecialHandle:true raise:false.
+    [con notNil] whileTrue:[
+        (s := con selector) == #'answer:do:' ifTrue:[
+            (s := con receiver) == self ifTrue:[
+"/ '0' printCR.
+                ^ con argAt:1
+            ].
+            (s accepts:self) ifTrue:[
+"/ '*2' printCR.
+                ^ super raiseRequest
+            ].
+        ] ifFalse:[
+            s == #'handle:do:' ifFalse:[
+"/ '*1a ' print. con printCR.
+                ^ super raiseRequest
+            ].
+            (s := con receiver) == self ifTrue:[
+"/ '*1b ' print. con printCR.
+                ^ super raiseRequest
+            ].
+            (s accepts:self) ifTrue:[
+"/ '*1c ' print. con printCR.
+                ^ super raiseRequest
+            ]
+        ].
+        con := con findSpecialHandle:true raise:false.
+    ].
 
-    "Created: / 2.3.1998 / 10:41:03 / stefan"
+    "/ no handler found - return the default value
+    hasDefault == true ifTrue:[
+"/ '3 ' print. self print. ' default: ' print. defaultAnswer printCR.
+        ^ defaultAnswer
+    ].
+    handlerBlock isNil ifTrue:[
+"/ '4 ' print. self print. ' nil: ' printCR.
+        ^ nil
+    ].
+"/ '*5 ' print. self print. ' handlerBlock' printCR.
+    ^ super raiseRequest
+
+    "Modified: / 15.6.1998 / 21:27:37 / cg"
+    "Modified: / 25.7.1999 / 23:35:11 / stefan"
 ! !
 
 !QuerySignal class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/QuerySignal.st,v 1.30 1999-08-02 15:03:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/QuerySignal.st,v 1.31 1999-08-03 12:56:24 cg Exp $'
 ! !