use _MAX_INT instead of 0x3fffffff in primitive code when generating SmallIntegers
--- a/Symbol.st Sat Mar 06 14:45:45 2010 +0100
+++ b/Symbol.st Sat Mar 06 14:45:51 2010 +0100
@@ -273,79 +273,78 @@
int l;
if (__Class(self) == Symbol) {
- val = __GET_HASH(self);
- /*
- * only do it, if I have no standard hash key
- * assigned (which can only happen due to a #become:,
- * or by creating a symbol uninterned, and interning it
- * after it got a hashKey assigned.
- */
- if (val == 0) {
- cp = __stringVal(self);
- l = __stringSize(self);
+ val = __GET_HASH(self);
+ /*
+ * only do it, if I have no standard hash key
+ * assigned (which can only happen due to a #become:,
+ * or by creating a symbol uninterned, and interning it
+ * after it got a hashKey assigned.
+ */
+ if (val == 0) {
+ cp = __stringVal(self);
+ l = __stringSize(self);
- /*
- * this is the dragon-book algorithm
- * We have tested 5-bit shifts as well:
- *
- * ST/X Symbols: 17807
- * Hashkey collisions (4bit): 14 0.07%
- * Hashkey collisions (5bit): 300 1.68%
- */
+ /*
+ * this is the dragon-book algorithm
+ * We have tested 5-bit shifts as well:
+ *
+ * ST/X Symbols: 17807
+ * Hashkey collisions (4bit): 14 0.07%
+ * Hashkey collisions (5bit): 300 1.68%
+ */
- if (l > 0) {
- val = cp[0];
- if (l > 1) {
- val = (val << 4) + cp[1];
- if (l > 2) {
- val = (val << 4) + cp[2];
- if (l > 3) {
- val = (val << 4) + cp[3];
- if (l > 4) {
- val = (val << 4) + cp[4];
- if (l > 5) {
- val = (val << 4) + cp[5];
- if (l > 6) {
- val = (val << 4) + cp[6];
- for (ce = cp + l, cp += 7; cp < ce; cp++) {
- if (g = (val & 0xF0000000)) {
- val ^= g >> 24;
- val ^= g;
- }
- val = (val << 4) + *cp;
- }
- }
- }
- }
- }
- }
- }
- } else {
- val = 0;
- }
- val = (val * 31415821) & 0x3fffffff;
- } else {
- val = __MAKE_HASH__(val);
- }
- RETURN ( __mkSmallInteger(val) );
+ if (l > 0) {
+ val = cp[0];
+ if (l > 1) {
+ val = (val << 4) + cp[1];
+ if (l > 2) {
+ val = (val << 4) + cp[2];
+ if (l > 3) {
+ val = (val << 4) + cp[3];
+ if (l > 4) {
+ val = (val << 4) + cp[4];
+ if (l > 5) {
+ val = (val << 4) + cp[5];
+ if (l > 6) {
+ val = (val << 4) + cp[6];
+ for (ce = cp + l, cp += 7; cp < ce; cp++) {
+ if (g = (val & 0xF0000000)) {
+ val ^= g >> 24;
+ val ^= g;
+ }
+ val = (val << 4) + *cp;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ val = 0;
+ }
+ val = (val * 31415821) & _MAX_INT;
+ } else {
+ val = __MAKE_HASH__(val);
+ }
+ RETURN ( __mkSmallInteger(val) );
}
%}.
^ super identityHash
"
- |hashColl hashSet|
+ |hashColl hashSet|
- hashColl := OrderedCollection new:20000.
- Symbol allInstancesDo:[:instance |
- hashColl add:instance identityHash
- ].
- hashSet := hashColl asSet.
+ hashColl := OrderedCollection new:20000.
+ Symbol allInstancesDo:[:instance |
+ hashColl add:instance identityHash
+ ].
+ hashSet := hashColl asSet.
- Transcript showCR:'Symbols: ', hashColl size printString,
- ' unique hash keys: ', hashSet size printString,
- ' collisions:', (hashColl size - hashSet size) printString.
+ Transcript showCR:'Symbols: ', hashColl size printString,
+ ' unique hash keys: ', hashSet size printString,
+ ' collisions:', (hashColl size - hashSet size) printString.
"
-
!
~= something
@@ -692,9 +691,9 @@
!Symbol class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.89 2009-11-05 16:25:14 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.90 2010-03-06 13:45:51 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.89 2009-11-05 16:25:14 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Symbol.st,v 1.90 2010-03-06 13:45:51 stefan Exp $'
! !