help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] faster sets project


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] faster sets project
Date: Fri, 17 Jul 2009 09:49:30 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Lightning/1.0pre Thunderbird/3.0b2


May be you can look at HashedCollection (the superclass of Dictionary and Set)

   addWhileGrowing: value [
        "Private - Add the newObject association to the receiver. Don't check 
for
         the set to be full - we want SPEED!."

        <category: 'private methods'>
        self primAt: (self findElementIndex: value) put: value.
        tally := tally + 1.
        ^value
     ]

    findElementIndex: anObject [
        "Tries to see where anObject can be placed as an indexed variable.
         As soon as nil is found, the index of that slot is answered.
         anObject also comes from an indexed variable."

        <category: 'private methods'>
        | index size element |
        self beConsistent.

        "Sorry for the lack of readability, but I want speed... :-)"
index := (anObject hash scramble bitAnd: (size := self primSize) - 1) + 1.

        [(element := self primAt: index) isNil
            ifTrue: [^index].
        index == size ifTrue: [index := 1] ifFalse: [index := index + 1]]
                repeat
    ]


(I use the GIT version of GST)

I think this has been there for years.

(Ralph, no offense intended of course. I understand the difficulty in reading a complex system and I understand you are used to having a browser. Luckily it's just a few months away... ;-)

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]