Speed hack dirty?
Christopher Oliver
oliver at fritz.co.traverse.com
Mon Jan 19 10:22:27 UTC 1998
In my cryptology program, I need to rotate a 32 bit value by a multiple
of eight bits. I started with:
bitRot: word32 by: bitCount
"Rotation of long words.
This really really belong with the integers."
^ ((word32 bitShift: bitCount)
+ (word32 bitShift: bitCount - 32))
bitAnd: 16rFFFFFFFF
However this is VERY slow. I rewrote this as three explicit methods
using digitAt: and digitAt:put: which speeds up the rotation by about
an order of magnitude.
The real question is just how forbidden is this sort of thing?
--
Christopher Oliver Traverse Communications
Systems Coordinator 223 Grandview Pkwy, Suite 108
oliver at traverse.com Traverse City, Michigan, 49684
(define magic (lambda (f) (lambda (x) x)))
(define (more-magic n) (lambda (f) (lambda (x) (f ((n f) x)))))
More information about the Squeak-dev
mailing list
|