fast mapping from viewID to view (experimental)
authorClaus Gittinger <cg@exept.de>
Sat, 01 Mar 1997 23:37:00 +0100
changeset 1406 2aa01c6279f0
parent 1405 4cdcc64344f4
child 1407 3528a4779c8b
fast mapping from viewID to view (experimental)
DevWorkst.st
DeviceWorkstation.st
--- a/DevWorkst.st	Sat Mar 01 22:56:19 1997 +0100
+++ b/DevWorkst.st	Sat Mar 01 23:37:00 1997 +0100
@@ -3695,7 +3695,11 @@
 initialize
     "initialize the receiver for a connection to the default display"
 
+    idToViewMapping := WeakValueDictionary new:100.
+
     ^ self initializeFor:nil
+
+    "Modified: 1.3.1997 / 20:01:14 / cg"
 !
 
 initializeDeviceResources
@@ -4742,11 +4746,15 @@
     knownViews at:freeIdx put:aView.
     knownIds at:freeIdx put:aWindowID.
 
+    idToViewMapping notNil ifTrue:[
+        idToViewMapping at:aWindowID put:aView.
+    ].
+
 "/    dispatching ifFalse:[
 "/        self startDispatch
 "/    ].
 
-    "Modified: 22.12.1995 / 22:46:09 / cg"
+    "Modified: 1.3.1997 / 20:00:08 / cg"
 !
 
 removeKnownView:aView
@@ -4756,8 +4764,6 @@
 
     aView isNil ifTrue:[^ self].
 
-"/    idToViewMapping removeValue:aView ifAbsent:[].
-
     lastId := nil.
     lastView := nil.
 
@@ -4766,11 +4772,13 @@
 
         index := knownViews identityIndexOf:aView.
         index == 0 ifFalse:[
+            idToViewMapping notNil ifTrue:[
+                idToViewMapping removeKey:(knownIds at:index) ifAbsent:nil.
+            ].
             knownViews at:index put:nil.
             knownIds at:index put:nil.
             lastId := nil.
             lastView := nil.
-
         ].
 
         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -4778,7 +4786,7 @@
         self checkForEndOfDispatch.
     ]
 
-    "Modified: 23.1.1997 / 21:31:22 / cg"
+    "Modified: 1.3.1997 / 20:02:16 / cg"
 !
 
 update:something with:aParameter from:changedObject
@@ -4800,15 +4808,17 @@
             or:[v == 0]) ifTrue:[
                 id := knownIds at:idx.
                 id notNil ifTrue:[
+                    idToViewMapping notNil ifTrue:[
+                        idToViewMapping removeKey:id.
+                    ].
                     knownIds at:idx put:nil.
                 ].
             ]
         ].
-        
     ]
 
-    "Modified: 24.4.1996 / 19:39:46 / cg"
     "Created: 21.6.1996 / 19:21:16 / cg"
+    "Modified: 1.3.1997 / 19:59:32 / cg"
 !
 
 viewFromId:aWindowID
@@ -4816,7 +4826,10 @@
 
     |index v|
 
-"/    ^ idToViewMapping at:aNumber ifAbsent:[nil].
+    idToViewMapping notNil ifTrue:[
+        v := idToViewMapping at:aWindowID ifAbsent:nil.
+        (v notNil and:[v ~~ 0]) ifTrue:[^ v].
+    ].
 
     aWindowID = lastId ifTrue:[
         lastView notNil ifTrue:[
@@ -4839,7 +4852,7 @@
 
     ^ v
 
-    "Modified: 23.1.1997 / 21:42:56 / cg"
+    "Modified: 1.3.1997 / 20:04:31 / cg"
 ! !
 
 !DeviceWorkstation methodsFor:'window stuff'!
@@ -5117,6 +5130,6 @@
 !DeviceWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.179 1997-02-26 14:04:51 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.180 1997-03-01 22:37:00 cg Exp $'
 ! !
 DeviceWorkstation initialize!
--- a/DeviceWorkstation.st	Sat Mar 01 22:56:19 1997 +0100
+++ b/DeviceWorkstation.st	Sat Mar 01 23:37:00 1997 +0100
@@ -3695,7 +3695,11 @@
 initialize
     "initialize the receiver for a connection to the default display"
 
+    idToViewMapping := WeakValueDictionary new:100.
+
     ^ self initializeFor:nil
+
+    "Modified: 1.3.1997 / 20:01:14 / cg"
 !
 
 initializeDeviceResources
@@ -4742,11 +4746,15 @@
     knownViews at:freeIdx put:aView.
     knownIds at:freeIdx put:aWindowID.
 
+    idToViewMapping notNil ifTrue:[
+        idToViewMapping at:aWindowID put:aView.
+    ].
+
 "/    dispatching ifFalse:[
 "/        self startDispatch
 "/    ].
 
-    "Modified: 22.12.1995 / 22:46:09 / cg"
+    "Modified: 1.3.1997 / 20:00:08 / cg"
 !
 
 removeKnownView:aView
@@ -4756,8 +4764,6 @@
 
     aView isNil ifTrue:[^ self].
 
-"/    idToViewMapping removeValue:aView ifAbsent:[].
-
     lastId := nil.
     lastView := nil.
 
@@ -4766,11 +4772,13 @@
 
         index := knownViews identityIndexOf:aView.
         index == 0 ifFalse:[
+            idToViewMapping notNil ifTrue:[
+                idToViewMapping removeKey:(knownIds at:index) ifAbsent:nil.
+            ].
             knownViews at:index put:nil.
             knownIds at:index put:nil.
             lastId := nil.
             lastView := nil.
-
         ].
 
         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -4778,7 +4786,7 @@
         self checkForEndOfDispatch.
     ]
 
-    "Modified: 23.1.1997 / 21:31:22 / cg"
+    "Modified: 1.3.1997 / 20:02:16 / cg"
 !
 
 update:something with:aParameter from:changedObject
@@ -4800,15 +4808,17 @@
             or:[v == 0]) ifTrue:[
                 id := knownIds at:idx.
                 id notNil ifTrue:[
+                    idToViewMapping notNil ifTrue:[
+                        idToViewMapping removeKey:id.
+                    ].
                     knownIds at:idx put:nil.
                 ].
             ]
         ].
-        
     ]
 
-    "Modified: 24.4.1996 / 19:39:46 / cg"
     "Created: 21.6.1996 / 19:21:16 / cg"
+    "Modified: 1.3.1997 / 19:59:32 / cg"
 !
 
 viewFromId:aWindowID
@@ -4816,7 +4826,10 @@
 
     |index v|
 
-"/    ^ idToViewMapping at:aNumber ifAbsent:[nil].
+    idToViewMapping notNil ifTrue:[
+        v := idToViewMapping at:aWindowID ifAbsent:nil.
+        (v notNil and:[v ~~ 0]) ifTrue:[^ v].
+    ].
 
     aWindowID = lastId ifTrue:[
         lastView notNil ifTrue:[
@@ -4839,7 +4852,7 @@
 
     ^ v
 
-    "Modified: 23.1.1997 / 21:42:56 / cg"
+    "Modified: 1.3.1997 / 20:04:31 / cg"
 ! !
 
 !DeviceWorkstation methodsFor:'window stuff'!
@@ -5117,6 +5130,6 @@
 !DeviceWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.179 1997-02-26 14:04:51 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.180 1997-03-01 22:37:00 cg Exp $'
 ! !
 DeviceWorkstation initialize!