[squeak-dev] Re: The defaullt implementation of isEmpty might do too
monty2 at programmer.net
Fri Oct 21 22:59:48 UTC 2016
All non-trivial collections implement #size or inherit a custom implementation, usually just as a return of an inst var. Your #do:-based one is 3x as slow in my tests, so you've now made #isEmpty slower for every collection that implements #size just to benefit ones whose careless authors didn't and so the implementors of lazy collections have one fewer message to override.
Do not do this. People already avoid #ifEmpty: and related messages where performance matters and shouldn't have to avoid #isEmpty too.
More information about the Squeak-dev