--- a/Registry.st Thu Feb 20 14:26:53 1997 +0100
+++ b/Registry.st Mon Feb 24 21:24:44 1997 +0100
@@ -11,7 +11,7 @@
"
Object subclass:#Registry
- instanceVariableNames:'registeredObjects handleArray tally'
+ instanceVariableNames:'registeredObjects handleArray tally indexTable'
classVariableNames:''
poolDictionaries:''
category:'System-Support'
@@ -171,6 +171,7 @@
realNewSize := tally * 3 // 2.
newObjects := WeakArray new:realNewSize.
newHandles := Array new:realNewSize.
+ indexTable := WeakIdentityDictionary new.
wasBlocked := OperatingSystem blockInterrupts.
@@ -184,6 +185,8 @@
].
newObjects at:dstIndex put:phantom.
newHandles at:dstIndex put:(handleArray at:index).
+ indexTable at:phantom put:dstIndex.
+
dstIndex := dstIndex + 1
]
].
@@ -223,8 +226,12 @@
registeredObjects := WeakArray new:10.
registeredObjects addDependent:self.
handleArray := Array basicNew:10.
+ indexTable := WeakIdentityDictionary new.
+
registeredObjects at:1 put:anObject.
handleArray at:1 put:aHandle.
+ indexTable at:anObject put:1.
+
tally := 1.
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
ObjectMemory addDependent:self.
@@ -236,7 +243,8 @@
OperatingSystem blockInterrupts.
].
- index := registeredObjects identityIndexOf:anObject ifAbsent:0.
+ "/ index := registeredObjects identityIndexOf:anObject ifAbsent:0.
+ index := indexTable at:anObject ifAbsent:0.
index ~~ 0 ifTrue:[
"already registered"
handleArray at:index put:aHandle.
@@ -266,6 +274,8 @@
].
registeredObjects at:index put:anObject.
handleArray at:index put:aHandle.
+ indexTable at:anObject put:index.
+
tally := tally + 1.
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
^ self
@@ -286,6 +296,8 @@
newPhantoms replaceFrom:1 to:size with:handleArray.
handleArray := newPhantoms.
handleArray at:index put:aHandle.
+ indexTable at:anObject put:index.
+
tally := tally + 1.
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -303,7 +315,8 @@
registeredObjects isNil ifTrue:[
index := 0
] ifFalse:[
- index := registeredObjects identityIndexOf:anObject ifAbsent:0.
+ "/ index := registeredObjects identityIndexOf:anObject ifAbsent:0.
+ index := indexTable at:anObject ifAbsent:0.
].
index ~~ 0 ifTrue:[
handleArray at:index put:anObject shallowCopyForFinalization.
@@ -324,10 +337,12 @@
registeredObjects notNil ifTrue:[
wasBlocked := OperatingSystem blockInterrupts.
- index := registeredObjects identityIndexOf:anObject ifAbsent:0.
+ "/ index := registeredObjects identityIndexOf:anObject ifAbsent:0.
+ index := indexTable at:anObject ifAbsent:0.
index ~~ 0 ifTrue:[
handleArray at:index put:nil.
registeredObjects at:index put:nil.
+ indexTable removeKey:anObject.
tally := tally - 1.
].
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -350,12 +365,14 @@
registeredObjects notNil ifTrue:[
wasBlocked := OperatingSystem blockInterrupts.
n := registeredObjects size.
+
1 to:n do:[:index |
obj := registeredObjects at:index.
(obj notNil and:[obj ~~ 0]) ifTrue:[
(aBlock value:obj) ifTrue:[
handleArray at:index put:nil.
registeredObjects at:index put:nil.
+ indexTable removeKey:obj.
tally := tally - 1.
]
]
@@ -371,5 +388,5 @@
!Registry class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Registry.st,v 1.39 1997-01-27 14:18:48 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Registry.st,v 1.40 1997-02-24 20:24:44 cg Exp $'
! !