[squeak-dev] Undeclared -> WeakIdentityDictionary -> wrong tally -> wrong #size

marcel.taeumel Marcel.Taeumel at hpi.de
Wed Feb 26 12:55:52 UTC 2020


Hmm... for all kinds of HashedCollection, there is #size and #slowSize. The
latter is more precise for weak collections, which answer only an upper
bound via #size. Because they cannot know better. While this might be
resolved with using ephemerons at some point, I still wonder whether
#isEmpty should really just use the tally or not:

HashedCollection >> #isEmpty
   ^tally = 0

We added this in 10/20/2016. Maybe we should override #isEmpty in all our
weak collections if they do not rely on #do as intended in Collection:

Collection >> #isEmpty
   self do: [:element | ^ false].
   ^ true

#do: works fine for those weak collections. I suppose it is as slow as
#slowSize. :-)

Best,
Marcel


marcel.taeumel wrote
> Hi, there.
> 
> In Squeak 5.3 RC1, the size of Undeclared is wrong. It should be 1 (which
> is also wrong but I fixed that), but is actually 31.
> 
> WeakIdentityDictionary (HashedCollection) >> #size
>    ^ tally
> 
> Well, there might be a bug lurking somewhere. Maybe an update script
> messed up the state of Undeclared in particular. I don't know.
> 
> What should I do? Just fix that value for tally in Undeclared?
> 
> Best,
> Marcel
> 
> P.S.: The #capacity of Undeclared is 3, which is correct because the
> internal WeakArray array has that size.





--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html


More information about the Squeak-dev mailing list