DateAndTime hash was: Re: [squeak-dev] true hash

Paul DeBruicker pdebruic at gmail.com
Fri May 11 00:07:54 UTC 2012


On 05/10/2012 02:18 PM, Nicolas Cellier wrote:
> Maybe something like this
>
> hash
> 	| totalSeconds |
> 	totalSeconds := seconds - offset asSeconds.
> 	^ ((totalSeconds // 86400 + jdn) hashMultiply bitXor: totalSeconds \\
> 86400) bitXor: nanos
>
> Nicolas


That does well too.  Its better than what I proposed as far as 
collisions go but a little bit slower on my machine.  It has ~1 
collision per 10,000 and is 100x faster than the original hash method.


Your test doesn't fail with the hash I proposed on Pharo-1.3 but 
definitely fails on Squeak4.3.


I'll put up and amended version in the inbox with your hash and modify 
the Pharo issue.


Also in Squeak 4.3 these test fail after the hash change because they 
test that the hash is a specific SmallInteger

DateAndTimeEpochTest>>#testHash
DateAndTimeLeapTest>>#testHash
TimespanTest>>#testHash


More information about the Squeak-dev mailing list