[squeak-dev] The Inbox: Kernel-pad.664.mcz

commits at source.squeak.org commits at source.squeak.org
Fri May 11 00:11:26 UTC 2012


A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-pad.664.mcz

==================== Summary ====================

Name: Kernel-pad.664
Author: pad
Time: 10 May 2012, 5:10:40.385 pm
UUID: 28502175-6089-4462-817c-d67569aae40e
Ancestors: Kernel-pad.663

Nicolas Cellier proposed this hash which has fewer collisions than the one I proposed (~1 per 10,000) and is still plenty fast (100x faster than the original).  It also can handle the following test:

| date1 date2 |
date1 := DateAndTime new ticks: (DateAndTime unixEpoch + 1 hours)
ticks offset: 0 hours.
date2 := DateAndTime new ticks: (DateAndTime unixEpoch - 2 hours)
ticks offset: -3 hours.
self assert: (date1 = date2) ==> [date1 hash = date2 hash]

=============== Diff against Kernel-pad.663 ===============

Item was changed:
  ----- Method: DateAndTime>>hash (in category 'ansi protocol') -----
  hash
+ 	| totalSeconds |
+ 	totalSeconds := seconds - offset asSeconds.
+ 	^ ((totalSeconds // 86400 + jdn) hashMultiply bitXor: totalSeconds \\
+ 86400) bitXor: nanos!
- 	^ (jdn hashMultiply bitXor: seconds + offset asSeconds) bitXor: nanos!



More information about the Squeak-dev mailing list