[squeak-dev] Re: [ANN] Kernel methods license audit
Paolo Bonzini
bonzini at gnu.org
Fri Mar 21 08:26:08 UTC 2008
> However, looking at the source, apart accessors, some methods will
> hardly ever change, like:
> Integer>>bitInvert
> ^-1-self
>
> There is no added value in such method but very obvious algorithm:
> two complement: bitinvert the digits, and add 1
> => bitInvert: take two complement, and subtract 1
This could become "^self bitXor: -1", at least if bitXor does not use
bitInvert. :-)
> The trick is not here, it is in pretending LargeNegativeInteger are
> stored in two complements, what they are not...
> So the trick is in all the bitOr:, bitAnd:, bitXor:, bitShift:
> implementations, as a whole.
If you want a >0% chance to have different code, look at libgst/mpz.c
from GNU Smalltalk. It contains the exact same algorithms written in C
(so don't be afraid of tainting anything with anything). And XOR does
not use NOT so you get a chance to rewrite #bitInvert too. :-)
Paolo
More information about the Squeak-dev
mailing list
|