koschate wrote:Maybe it's naive of me, but I would have expected #odd to have been implemented as
^self even not
both for obviousness and DRY principles. In terms of performance, I don't think there's a hit, and this would have avoided the problem.
It actually makes a big difference:
100,000,000 loops of self even not
takes 3.930 seconds on my VMware Ubuntu machine
100,000,000 loops of (self bitAnd: 1) == 1
takes 2.784 seconds on the same machine
In very small methods, one extra message send can make a big difference -- I suppose that is why the methods weren't implemented in terms of themselves in the first place.
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.