[squeak-dev] The Trunk: Collections-ul.668.mcz
Chris Muller
asqueaker at gmail.com
Tue Oct 13 00:14:15 UTC 2015
This extra check halves the speed of Dictionary>>= when they are equal, for
all cases which consider equivalence symmetrical. If a=b, then it should
be able to be assumed that b=a. What case is it not?
On Mon, Oct 12, 2015 at 7:02 PM, <commits at source.squeak.org> wrote:
> Levente Uzonyi uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-ul.668.mcz
>
> ==================== Summary ====================
>
> Name: Collections-ul.668
> Author: ul
> Time: 13 October 2015, 1:07:48.216 am
> UUID: 8abfa05a-70c6-4e38-bc00-7d665183106c
> Ancestors: Collections-ul.667
>
> In Dictionary >> #=, make sure that the dictionaries agree on what the
> common keys are. This way the behaviour of #= will be symmetric when the
> two dictionaries implement key equality differently.
>
> =============== Diff against Collections-ul.667 ===============
>
> Item was changed:
> ----- Method: Dictionary>>= (in category 'comparing') -----
> + = anObject
> - = aDictionary
> "Two dictionaries are equal if
> (a) they are the same 'kind' of thing.
> (b) they have the same set of keys.
> (c) for each (common) key, they have the same value"
>
> + self == anObject ifTrue: [ ^true ].
> + anObject isDictionary ifFalse: [ ^false ].
> + self size = anObject size ifFalse: [ ^false ].
> + self associationsDo: [ :association |
> + (anObject at: association key ifAbsent: [ ^false ]) =
> association value
> + ifFalse: [ ^false ] ].
> + "The two dictionaries may have different ideas about equal keys,
> so check both ways to avoid any inconsistency."
> + anObject associationsDo: [ :association |
> + (self at: association key ifAbsent: [ ^false ]) =
> association value
> + ifFalse: [ ^false ] ].
> + ^true!
> - self == aDictionary ifTrue: [ ^ true ].
> - aDictionary isDictionary ifFalse: [^false].
> - self size = aDictionary size ifFalse: [^false].
> - self associationsDo: [:assoc|
> - (aDictionary at: assoc key ifAbsent: [^false]) = assoc
> value
> - ifFalse: [^false]].
> - ^true
> -
> - !
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20151012/e9ad2123/attachment.htm
More information about the Squeak-dev
mailing list
|