On 16.12.2011 00:40, Henrik Sperre Johansen wrote:
On 15.12.2011 23:35, Mariano Martinez Peck wrote:
Well...it is much slower :( it seems that the cost of (aKey
identityHash + ( aKey mareaClass identityHash bitShift: 12) + (aKey
basicSize bitShift: 24)
is bigger than the colisions.
Anyway, thanks for the nice thread. I learned.
Cheers
Well, first of all, that always creates a largeInteger, since
identityHash is already shifted by 22... You'd want to be using
basicIdentityHash.
2nd off, basicSize is useless for non-variable classes, which I guess
is the common case.
3rd, putting class hash in the high bits won't really help much if
you're serializing many instances of the same class, as they will all
occupy a sequential hash range.
So if I were you, I'd try with something like
obj basicIdentityHash << 12 + (obj class basicIdentityHash)
before discarding it outright due to computation cost.
Cheers,
Henry
Note: This is not portable to Squeak.
They kept the old version of identityHash (renamed to basicIdentityHash
in Pharo), and introduced scaledIdentityHash (doing the same as
identityHash in Pharo), due to backwards compatability concerns for
users explicitly relying on #identityHash returning a value in range [0,
4095].
Cheers,
Henry