Hi guys
I would love to have a better method comment for hashMultiply | low | low := self bitAnd: 16383. ^(16r260D * low + ((16r260D * (self bitShift: -14) + (16r0065 * low) bitAnd: 16383) * 16384)) bitAnd: 16r0FFFFFFF Some love? Stef |
It's not documented because hashing is complex... The goal is to shuffle the receiver bits and distribute them over the available 28bits used for hash codes.why and how it does so is a tough subject, Andres Valloud wrote a whole book on it ;) The basic operation which is emulated is relatively simple, but implementation is overly complex, because it tries to avoid creating LargeIntegers in 32bits VM 2017-11-16 22:25 GMT+01:00 Stephane Ducasse <[hidden email]>: Hi guys hashMultiply.st (1K) Download Attachment |
2017-11-16 23:32 GMT+01:00 Nicolas Cellier <[hidden email]>:
|
One little action is worth a thousand words :)
2017-11-17 11:51 GMT+01:00 Pavel Krivanek <[hidden email]>:
|
Indeed no little action is worth a thousand words.
Everybody plants its own seed. Tx nicolas and Pavel. Stef On Fri, Nov 17, 2017 at 3:00 PM, Nicolas Cellier <[hidden email]> wrote: > One little action is worth a thousand words :) > > > 2017-11-17 11:51 GMT+01:00 Pavel Krivanek <[hidden email]>: >> >> https://github.com/pharo-project/pharo/pull/487 >> >> 2017-11-16 23:32 GMT+01:00 Nicolas Cellier >> <[hidden email]>: >>> >>> It's not documented because hashing is complex... >>> The goal is to shuffle the receiver bits and distribute them over the >>> available 28bits used for hash codes. >>> why and how it does so is a tough subject, Andres Valloud wrote a whole >>> book on it ;) >>> >>> The basic operation which is emulated is relatively simple, but >>> implementation is overly complex, because it tries to avoid creating >>> LargeIntegers in 32bits VM >>> >>> *16384 is <=> bitShift: 14 >>> bitAnd 16383 is <=> isolating lowest 14 bits... >>> >>> While at it, one should also rewrite the method contents in order to use >>> the new primitive available >>> and profit by more efficient 64bit version for 64bit VM... >>> >>> Fortunately, one can still pick the methods from Squeak :) >>> then forget the original authors because it really does not matter, does >>> it? >>> >>> >>> 2017-11-16 22:25 GMT+01:00 Stephane Ducasse <[hidden email]>: >>>> >>>> Hi guys >>>> >>>> I would love to have a better method comment for >>>> >>>> >>>> hashMultiply >>>> | low | >>>> low := self bitAnd: 16383. >>>> ^(16r260D * low + ((16r260D * (self bitShift: -14) + (16r0065 * >>>> low) bitAnd: 16383) * 16384)) >>>> bitAnd: 16r0FFFFFFF >>>> >>>> >>>> Some love? >>>> >>>> Stef >>>> >>> >> > |
Free forum by Nabble | Edit this page |