[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-smalltalk] copying RBSmallDictionary
From: |
Paolo Bonzini |
Subject: |
Re: [Help-smalltalk] copying RBSmallDictionary |
Date: |
Wed, 10 Jan 2007 08:28:11 +0100 |
User-agent: |
Thunderbird 1.5.0.9 (Macintosh/20061207) |
This happens because RBSmallDictionary>>#findIndex: is wrong for
LookupTable, which expects a valid index. I fixed this by removing
RBSmallDictionary class>>#new: outright. I think this could also be
fixed with more faith to the original by using primNew: instead of
basicNew: in that method, but it doesn't bother me that much.
Try this. (The incrementTally change is only for efficiency).
--- orig/compiler/ParseTreeSearcher.st
+++ mod/compiler/ParseTreeSearcher.st
@@ -277,6 +277,17 @@ LookupTable variableSubclass: #RBSmallDi
!RBSmallDictionary methodsFor: 'private'!
+whileGrowingAt: key put: value
+ tally := tally + 1.
+ self primAt: self size put: key.
+ self valueAt: self size put: value!
+
+incrementTally
+ tally := tally + 1.
+ ^tally > self primSize
+ ifTrue: [ self grow ];
+ yourself!
+
findIndex: anObject
"Tries to see if anObject exists as an indexed variable. As soon
as nil
or anObject is found, the index of that slot is answered"
@@ -288,6 +299,7 @@ findIndex: anObject
(element isNil or: [ element = anObject ])
ifTrue: [ ^i ]
].
+ tally = self primSize ifTrue: [ self grow ].
^self size + 1! !
RBSmallDictionary class
Paolo