[squeak-dev] The Inbox: Collections-cbc.810.mcz

Chris Muller asqueaker at gmail.com
Tue Oct 30 04:04:16 UTC 2018


Good finds and also this analysis of trade-off implementations for
Interval>>#hash!  I definitely don't understand the implications of
each ("size - 15"?), but this cool try-it-out package enables a level
of collaboration that almost brings a tear to my eye.  Awesome.

Thanks Chris.  :)


On Sun, Oct 28, 2018 at 7:16 PM <commits at source.squeak.org> wrote:
>
> Chris Cunningham uploaded a new version of Collections to project The Inbox:
> http://source.squeak.org/inbox/Collections-cbc.810.mcz
>
> ==================== Summary ====================
>
> Name: Collections-cbc.810
> Author: cbc
> Time: 28 October 2018, 5:15:56.960512 pm
> UUID: 729c4dd2-f677-3c40-9ded-4a407a71f824
> Ancestors: Collections-topa.809
>
> Do NOT move to trunk!
> Various option for fixing the internval hash issue related to collectionsTests cbc.296.
>
> Some explanation to go to mailing list - this is so interested folks can try out the code.
>
> =============== Diff against Collections-topa.809 ===============
>
> Item was added:
> + ----- Method: Array>>hashBetterFastIntervalCompatible (in category 'comparing') -----
> + hashBetterFastIntervalCompatible
> +       | hash |
> +       self size < 48 ifTrue: [^super hash]. "Just check every element."
> +       hash := self species hash.
> +       1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
> +       self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
> +       ^(hash + self size hash) hashMultiply!
>
> Item was added:
> + ----- Method: Array>>hashFastIntervalCompatible (in category 'comparing') -----
> + hashFastIntervalCompatible
> +       self size = 0 ifTrue: [^self species hash].
> +       ^(self species hash +
> +               (((((self at: 1) hash bitShift: 2)
> +                       bitOr: (self at: self size) hash)
> +                       bitShift: 1)
> +                       bitOr: self size)
> +               ) hashMultiply!
>
> Item was changed:
>   ----- Method: Interval>>hash (in category 'comparing') -----
>   hash
>         "Hash is reimplemented because = is implemented."
>
>         ^(((start hash bitShift: 2)
>                 bitOr: stop hash)
>                 bitShift: 1)
>                 bitOr: self size!
>
> Item was added:
> + ----- Method: Interval>>hashBetter (in category 'comparing') -----
> + hashBetter
> +       "Hash is reimplemented because = is implemented."
> +
> +       ^(((start hash bitShift: 2)
> +               bitOr: self last hash)
> +               bitShift: 1)
> +               bitOr: self size!
>
> Item was added:
> + ----- Method: Interval>>hashBetterAlsoFixBug3380 (in category 'comparing') -----
> + hashBetterAlsoFixBug3380
> +       "Hash is reimplemented because = is implemented."
> +       "Altered so that we has the same as self asArray hash"
> +       ^self inject: Array hash into: [:workingHash :each| (workingHash + each hash) hashMultiply ].!
>
> Item was added:
> + ----- Method: Interval>>hashBetterFastArrayCompatible (in category 'comparing') -----
> + hashBetterFastArrayCompatible
> +       | hash |
> +       self size < 48 ifTrue: [^self slowHash]. "Just check every element."
> +       hash := Array hash.
> +       1 to: 16 do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
> +       self size - 15 to: self size do: [:i| hash := (hash + (self at: i) hash) hashMultiply].
> +       ^(hash + self size hash) hashMultiply!
>
> Item was added:
> + ----- Method: Interval>>hashFastArrayCompatible (in category 'comparing') -----
> + hashFastArrayCompatible
> +       "Hash is reimplemented because = is implemented."
> +       self size = 0 ifTrue: [^Array hash].
> +       ^(Array hash +
> +               ((((start hash bitShift: 2)
> +                       bitOr: self last hash)
> +                       bitShift: 1)
> +                       bitOr: self size)
> +               ) hashMultiply!
>
> Item was added:
> + ----- Method: Interval>>hashSlowerBetterAlsoFixBug3380 (in category 'comparing') -----
> + hashSlowerBetterAlsoFixBug3380
> +       "Hash is reimplemented because = is implemented."
> +       "Altered so that we has the same as self asArray hash"
> +       | hash |
> +
> +       hash := Array hash.
> +       1 to: self size do: [:i | hash := (hash + (self at: i) hash) hashMultiply].
> +       ^hash!
>
> Item was added:
> + ----- Method: Interval>>slowHash (in category 'comparing') -----
> + slowHash
> +       "Hash is reimplemented because = is implemented."
> +       "Altered so that we has the same as self asArray hash"
> +       ^self inject: Array hash into: [:workingHash :each| (workingHash + each hash) hashMultiply ].!
>
>


More information about the Squeak-dev mailing list