--- a/Object.st Fri Mar 21 16:07:33 1997 +0100
+++ b/Object.st Fri Mar 21 17:42:57 1997 +0100
@@ -1394,6 +1394,70 @@
^ 0 "never reached, since redefined in UndefinedObject and SmallInteger"
!
+identityHashForBinaryStore
+ "hash which is usable if the object does not change its class
+ and does not #become something else, while the hash is used.
+ This is only used by the binary storage mechanism, during the
+ object writing phase."
+
+%{ /* NOCONTEXT */
+
+ REGISTER unsigned hash, hash1, hash2, sz;
+ OBJ o;
+ static unsigned nextHash = 0;
+
+ if (__isNonNilObject(self)) {
+ /*
+ * my own identityHash
+ */
+ hash1 = __GET_HASH(self);
+ if (hash1 == 0) {
+ /* has no hash yet */
+
+ if (nextHash < __MAX_HASH__) {
+ hash1 = ++nextHash;
+ } else {
+ hash1 = nextHash = 1;
+ }
+
+ __SET_HASH(self, hash1);
+ }
+ /*
+ * my classes identityHash
+ */
+ o = __Class(self);
+ hash2 = __GET_HASH(o);
+ if (hash2 == 0) {
+ /* has no hash yet */
+
+ if (nextHash < __MAX_HASH__) {
+ hash2 = ++nextHash;
+ } else {
+ hash2 = nextHash = 1;
+ }
+
+ __SET_HASH(o, hash2);
+ }
+
+ /*
+ * 8 bits of my size
+ */
+ sz = __qSize(self);
+
+ /*
+ * now, we got 11 + 11 + 8 bits for hashing;
+ * make it as large as possible; since most hashers use the returned
+ * key and take it modulu some prime number, this will allow for
+ * better distribution (i.e. bigger empty spaces) in hashed collection.
+ */
+ hash = (hash1 << 11) | hash2; /* 22 bits */
+ hash = (hash << 8) | (sz & 0xFF); /* 30 bits */
+ RETURN ( __MKSMALLINT(hash) );
+ }
+%}.
+ ^ 0 "never reached, since UndefinedObject and SmallInteger are not hashed upon in binary storage"
+!
+
isNil
"return true, if the receiver is nil"
@@ -5656,6 +5720,6 @@
!Object class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.182 1997-03-21 15:07:33 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.183 1997-03-21 16:42:57 cg Exp $'
! !
Object initialize!