class: CharacterArray
changed: #hash
changed: #hash_sdbm
Use hash_sdbm now.
--- a/CharacterArray.st Wed Jan 09 21:39:58 2013 +0100
+++ b/CharacterArray.st Wed Jan 09 21:40:35 2013 +0100
@@ -1966,8 +1966,8 @@
"/ immediately after any change, execute (maybe in a debugger):
"/ Set allSubInstancesDo:[:s | s rehash]
- ^ self hash_dragonBook
- "/ ^ self hash_sdbm.
+ "/ ^ self hash_dragonBook
+ ^ self hash_sdbm.
"
'a' hash
@@ -1980,6 +1980,44 @@
'ab' asArray hash
"
+ "
+ |syms ms|
+
+ syms := Symbol allInstances.
+ Transcript show:'syms: '; showCR:syms size.
+ Transcript show:'sdbm hashes: '; showCR:(syms collect:[:s| s hash_sdbm]) asSet size.
+ Transcript show:'dragonBook hashes: '; showCR:(syms collect:[:s| s hash_dragonBook]) asSet size.
+
+ ms := Time millisecondsToRun:[
+ 10 timesRepeat:[
+ syms do:[:each| each hash_sdbm].
+ ].
+ ].
+ Transcript show:'sdbm hash: '; showCR:ms.
+
+ ms := Time millisecondsToRun:[
+ 10 timesRepeat:[
+ syms do:[:each| each hash_dragonBook].
+ ].
+ ].
+ Transcript show:'dragonBook: '; showCR:ms.
+
+ syms := syms collect:[:each| each asUnicode16String].
+ ms := Time millisecondsToRun:[
+ 10 timesRepeat:[
+ syms do:[:each| each hash_sdbm].
+ ].
+ ].
+ Transcript show:'unicode sdbm hash: '; showCR:ms.
+
+ ms := Time millisecondsToRun:[
+ 10 timesRepeat:[
+ syms do:[:each| each hash_dragonBook].
+ ].
+ ].
+ Transcript show:'unicode dragonBook:'; showCR:ms.
+ "
+
"Modified: / 26-12-2011 / 14:09:07 / cg"
!
@@ -2035,10 +2073,9 @@
"/
h := 0.
self do:[:char |
- h := (h * 65599) + char codePoint.
- h := h bitAnd:16r3FFFFFFF.
+ h := (65599 times:h) plus:char codePoint.
].
- ^ h
+ ^ h
"
'a' hash_sdbm
@@ -6135,11 +6172,11 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.488 2013-01-09 12:48:49 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.489 2013-01-09 20:40:35 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.488 2013-01-09 12:48:49 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.489 2013-01-09 20:40:35 stefan Exp $'
! !