X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fbignum.lisp;h=c07fc192847b4b01754a2b4d357869d7312b59d4;hb=731da68c7e3b7f2c4bc310aa75fc75f5aead24d2;hp=9374acc1c0580919454f9ee5e7158575264c4074;hpb=e6aef26131543d369edf107df8fb94053646d1f4;p=sbcl.git diff --git a/src/code/bignum.lisp b/src/code/bignum.lisp index 9374acc..c07fc19 100644 --- a/src/code/bignum.lisp +++ b/src/code/bignum.lisp @@ -1320,16 +1320,18 @@ (defun bignum-logcount (bignum) (declare (type bignum-type bignum)) - (let* ((length (%bignum-length bignum)) - (plusp (%bignum-0-or-plusp bignum length)) - (result 0)) + (let ((length (%bignum-length bignum)) + (result 0)) (declare (type bignum-index length) (fixnum result)) (do ((index 0 (1+ index))) - ((= index length) result) + ((= index length) + (if (%bignum-0-or-plusp bignum length) + result + (- (* length digit-size) result))) (let ((digit (%bignum-ref bignum index))) (declare (type bignum-element-type digit)) - (incf result (logcount (if plusp digit (%lognot digit)))))))) + (incf result (logcount digit)))))) ;;;; logical operations