[squeak-dev] Re: The defaullt implementation of isEmpty might do
too much work
David T. Lewis
lewis at mail.msen.com
Thu Oct 27 00:46:56 UTC 2016
On Wed, Oct 26, 2016 at 05:51:40PM -0500, Chris Muller wrote:
> In exchange for these blemishes, how many classes actually got benefit
> from inheriting the new implementation?
> Collection allSubclasses count: [ : each | (each
> lookupSelector: #size) methodClass = Collection] "0"
Fair point. Every subclass of Collection reimplements #size in some way.
Collection>>size is never actually used by any class in the image, and
possibly not in any classes outside the image. So Collection>>size serves
as documentation of the intent, and as a default implementation if someone
were to implement a new subclass of Collection directly.
Some subclasses (e.g. Bag) would have similar characteristics and would presumably
benefit from the new #isEmpty implementation, but most seem to have #size
implementations that do not degrade in performance as size increases.
So Chris is raising a fair question. The new #isEmpty looks like it should be
faster, but is it actually so in practice?
p.s. I personally still prefer the new implementation on aesthetic grounds.
More information about the Squeak-dev