So, is there a way to avoid doing (floor x y) w/o consing extra memory? Even if there's an SBCL-specific way, that's good too.
- Code: Select all
(defun next-power-two-log (x)
(declare (optimize (debug 0) (safety 0) (space 0) (speed 3)))
(declare (type fixnum x))
(ash 1 (1+ (the signed-byte (floor (the single-float (log x 2)))))))
Here's an example of what I was trying to do, but it doesn't work because the type hint of signed-byte is ignored. But this is only to illustrate that even with speed 3, the second (and obviously redundant) value from floor is created and discarded.