[squeak-dev] The Trunk: Collections-eem.656.mcz

Eliot Miranda eliot.miranda at gmail.com
Sat Sep 26 18:32:07 UTC 2015


> On Sep 26, 2015, at 11:30 AM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 
> Hi Levente,
> 
>> On Sep 26, 2015, at 11:03 AM, Levente Uzonyi <leves at elte.hu> wrote:
>> 
>> Implementing #at:ifPresent:ifAbsentPut: without reusing #at:ifAbsent: and #at:ifAbsentPut: implies that it must be defined in some of its subclasses too to make it work.
>> This is the reason why #at:ifAbsentPut: and #at:ifPresent:ifAbsent: reuse the low-level methods, sacrificing performance.
> 
> I understand.  But a) using a single scanFor: saves half the search work in the ifAbsentPut: case and b) no extra effort is required if the subclass overrides scanFor: which is the real low level method.  So I'm happy with my decision.


And I'll take a look at subclasses soon.

> 
>> Levente
> 
> _,,,^..^,,,_ (phone)
> 
>> 
>>> On Fri, 25 Sep 2015, commits at source.squeak.org wrote:
>>> 
>>> Eliot Miranda uploaded a new version of Collections to project The Trunk:
>>> http://source.squeak.org/trunk/Collections-eem.656.mcz
>>> 
>>> ==================== Summary ====================
>>> 
>>> Name: Collections-eem.656
>>> Author: eem
>>> Time: 25 September 2015, 11:36:48.911 am
>>> UUID: 50ec1b3e-c058-4167-889e-836e994b500b
>>> Ancestors: Collections-ul.655
>>> 
>>> Add Dictionary>>at:ifPresent:ifAbsentPut:.
>>> Move Dictionary>>fasterKeys & keyForIdentity: to 50Deprecated
>>> 
>>> =============== Diff against Collections-ul.655 ===============
>>> 
>>> Item was added:
>>> + ----- Method: Dictionary>>at:ifPresent:ifAbsentPut: (in category 'accessing') -----
>>> + at: key ifPresent: oneArgBlock ifAbsentPut: absentBlock
>>> +    "Lookup the given key in the receiver. If it is present, answer the value of
>>> +     evaluating oneArgBlock with the value associated with the key. Otherwise
>>> +     add the value of absentBlock under the key, and answer that value."
>>> +
>>> +    | index value |
>>> +    index := self scanFor: key.
>>> +    (array at: index) ifNotNil:
>>> +        [:element|
>>> +         ^oneArgBlock value: element value].
>>> +    value := absentBlock value.
>>> +    self atNewIndex: index put: (Association key: key value: value).
>>> +    ^value!
>>> 
>>> Item was removed:
>>> - ----- Method: Dictionary>>fasterKeys (in category 'accessing') -----
>>> - fasterKeys
>>> -    "Contrary to old version of #keys, this method returned an Array rather than a Set.
>>> -    This was faster because no lookup: was performed.
>>> -    But now, #keys also return an Array, so don't use #fasterKeys anymore."
>>> -
>>> -    self deprecated: 'use #keys'.
>>> -
>>> -    ^self keys.
>>> - !
>>> 
>>> Item was removed:
>>> - ----- Method: Dictionary>>keyForIdentity: (in category 'accessing') -----
>>> - keyForIdentity: anObject
>>> -    "If anObject is one of the values of the receive, return its key, else return nil.  Contrast #keyAtValue: in which there is only an equality check, here there is an identity check"
>>> -
>>> -    self deprecated: 'Use #keyAtIdentityValue:ifAbsent:'.
>>> -    ^self keyAtIdentityValue: anObject ifAbsent: nil!
>> 


More information about the Squeak-dev mailing list