[squeak-dev] use of pointsTo: for includesSelector:

Levente Uzonyi leves at elte.hu
Fri Oct 25 22:49:26 UTC 2013


On Fri, 25 Oct 2013, David T. Lewis wrote:

> On Fri, Oct 25, 2013 at 02:18:07PM -0700, Eliot Miranda wrote:
>>
>> ProtoObject>>pointsTo: anObject
>> "This method returns true if self contains a pointer to anObject,
>> and returns false otherwise"
>> <primitive: 132>
>> 1 to: self class instSize do:
>> [:i | (self instVarAt: i) == anObject ifTrue: [^ true]].
>> 1 to: self basicSize do:
>> [:i | (self basicAt: i) == anObject ifTrue: [^ true]].
>> ^ false
>
> The version of ProtoObject>>pointsTo: that you quote here has a time stamp
> from 1999. The current version in Squeak has a time stamp of 2008, and
> looks like this:
>
>
> ProtoObject>>pointsTo: anObject
> "Answers true if I hold a reference to anObject, or false otherwise. Or stated another way:
>
> Answers true if the garbage collector would fail to collect anObject because I hold a reference to it, or false otherwise"
>
> 	^ (self instVarsInclude: anObject)
> 		or: [self class == anObject]

The old #pointsTo: method was renamed to #instVarsInclude: somewhere 
around Squeak 4.3. MethodDictionary used to use #instVarsInclude:, so the 
bug was still present in the Trunk, but I just removed the #includesKey: 
method in Kernel-ul.815, because we don't need the extra speed, nor the 
bug. :)

At the same time I have uploaded a new version of Collections, which has a 
slighly faster version of Dictionary >> #includesKey:.


Levente


More information about the Squeak-dev mailing list