class: SmallInteger
authorClaus Gittinger <cg@exept.de>
Tue, 23 Dec 2014 21:07:04 +0100
changeset 17247 e4e29302c10a
parent 17246 0e609e06e051
child 17248 bfcd59da8904
class: SmallInteger added: #hashMultiply
SmallInteger.st
--- a/SmallInteger.st	Tue Dec 23 21:05:45 2014 +0100
+++ b/SmallInteger.st	Tue Dec 23 21:07:04 2014 +0100
@@ -822,6 +822,7 @@
 ! !
 
 
+
 !SmallInteger methodsFor:'bit operators'!
 
 bitAnd:anInteger
@@ -2468,6 +2469,24 @@
     ^ self negated
 !
 
+hashMultiply
+    "used in some squeak code to generate an alternative hash value for integers"
+
+    |low|
+
+    low := self bitAnd: 16r3FFF.
+    ^ (9741 * low 
+      + ((9741 * (self bitShift: -14) + (101 * low) bitAnd: 16383) * 16384))
+        bitAnd: 16r0FFFFFFF
+
+    "
+     1 hashMultiply    
+     2 hashMultiply    
+     3 hashMultiply    
+     100 hashMultiply  
+    "
+!
+
 identityHash
     "return an integer useful for hashing on identity"
 
@@ -4543,11 +4562,11 @@
 !SmallInteger class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.225 2014-11-11 14:24:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.226 2014-12-23 20:07:04 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.225 2014-11-11 14:24:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/SmallInteger.st,v 1.226 2014-12-23 20:07:04 cg Exp $'
 ! !