[squeak-dev] The Trunk: Kernel-ul.709.mcz
Levente Uzonyi
leves at elte.hu
Tue Sep 4 13:37:23 UTC 2012
On Tue, 4 Sep 2012, Frank Shearar wrote:
> On 4 September 2012 00:06, <commits at source.squeak.org> wrote:
>> Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
>> Item was added:
>> + ----- Method: Process>>environmentAt:ifAbsentPut: (in category 'process specific') -----
>> + environmentAt: key ifAbsentPut: aBlock
>> +
>> + ^(env ifNil: [ env := Dictionary new ]) at: key ifAbsentPut: aBlock.!
>
> Given that Process >> #environmentAt:put: says "^ (env ifNil: [ env :=
> Dictionary new ]) at: key put: value" wouldn't it be better to defer
> the dictionary creation to it, or pull the two initialisation places
> into one, separate, place?
There are three things to consider:
- do we want to expose the dictionary itself?
- performance
- single initialization point
I picked the implementation with better performance and didn't want to
expose the dictionary. We can also have a single initialization point but
the code looks a bit unusual (at least to me):
Process >> #ensureEnvironment
env ifNil: [ env := Dictionary new ]
Process >> #environmentAt: key put: value
env ifNil: [ self ensureEnvironment ].
^env at: key put: value
Process >> #environmentAt: key ifAbsentPut: aBlock
env ifNil: [ self ensureEnvironment ].
^env at: key ifAbsentPut: aBlock
I can push a new version if you like this implementation more.
Levente
>
> frank
>
>> Item was added:
>> + ----- Method: ProtoObject>>pointsOnlyWeaklyTo: (in category 'tracing') -----
>> + pointsOnlyWeaklyTo: anObject
>> + "Assume, we already know that receiver points to an object, answer true if receiver points only weakly to it."
>> +
>> + self class isWeak ifFalse: [ ^false ].
>> + 1 to: self class instSize do: [ :i |
>> + (self instVarAt: i) == anObject ifTrue: [ ^false ] ].
>> + ^true!
>>
>>
>
>
More information about the Squeak-dev
mailing list
|