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

Igor Stasenko siguctua at gmail.com
Fri May 14 22:53:55 UTC 2010


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.



More information about the Squeak-dev mailing list