[squeak-dev] WideString hash is way slower than ByteString hash.

Igor Stasenko siguctua at gmail.com
Fri May 14 23:13:11 UTC 2010


And besides, if someone would bother implementing a primitive
for hasing the WideString, i doubt that he will go and create
an instances of Character for each indice, and then read its value and
only then use
it for hashing.
So, i don't think this is cheating. Its just an optimization :)
Of course, Cog , even if it optimize things cleverly, still has to
follow a code, and should create a real instances of Character,
simply because it is written so, and it should honor the language semantics.


On 15 May 2010 01:53, Igor Stasenko <siguctua at gmail.com> wrote:
> On 15 May 2010 01:38, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>> Hi Igor,
>>     is the NB implementation mapping the character codes in the wide strings
>> into Character objects and taking the character hashes?  If so, very cool.
>>  The NB code is very fast.  If on the other hand you're just
>> short-circuiting the character code lookup then you're cheating :)
>>
> What mapping you have in mind?
>
> WideString>>at: index
>        "Answer the Character stored in the field of the receiver indexed by
> the argument."
>        ^ Character value: (self wordAt: index).
>
> Character class>>value: anInteger
>        "Answer the Character whose value is anInteger."
>
>        anInteger > 255 ifTrue: [^self basicNew setValue: anInteger].
>        ^ CharacterTable at: anInteger + 1.
>
> (Character classPool at: #CharacterTable) withIndexDo: [:ch :i | self
> assert: (ch asInteger = (i-1))]
>
> So, it is 1:1 correspondence between word, stored in wide string (self
> wordAt: index),
> and Character value, used for hashing. So, no mapping required.
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list