Here is a minor change on digitMultiply which is useful when performing multiplication of positives modulo a power of 256. If I'm supposed to send derivative code somewhere else in order to discharge my duties under the license, would someone please remind me where? Please... no style comments. This is strictly to speed up Rabin encryption, and this is a private method. I already know it's an ugly derivative.
Thanks,
'From Squeak 1.23 of October 4, 1997 on 26 January 1998 at 9:31:10 am'!
!Cryptor methodsFor: 'private' stamp: 'cao 1/26/98 09:15'! fastMultiply: a by: b digits: d | prod carry digit k ab | (a digitLength = 1 and: [(a digitAt: 1) = 0]) ifTrue: [^ 0]. prod _ Integer new: d neg: false. "prod starts out all zero" 1 to: (b digitLength min: d) do: [:i | (digit _ b digitAt: i) ~= 0 ifTrue: [k _ i. carry _ 0. "Loop invariant: 0<=carry<=0377, k=i+j-1" 1 to: (a digitLength min: d + 1 - i) do: [:j | ab _ ((a digitAt: j) * digit) + carry + (prod digitAt: k). carry _ ab bitShift: -8. prod digitAt: k put: (ab bitAnd: 255). k _ k + 1]. k <= d ifTrue: [prod digitAt: k put: carry]]]. ^ prod normalize! !
squeak-dev@lists.squeakfoundation.org