LispWorks User Guide and Reference Manual > 9 The Compiler > 9.6 Optimizing your code > 9.6.2 Fast 32-bit arithmetic

NextPrevUpTopContentsIndex

9.6.2.3 INT32 Optimization

The optimization works safely but without boxing when possible. You need

(optimize (float 0))

to get the optimization. This float level affects whether INT32 operations are optimized. This declaration must be placed at the start of a function (not on an inner let or locally form).

In this example the safety level assures a second optimization in fli:foreign-typed-aref :

(defun incf-signed-byte-32 (ptr index)
  (declare (optimize (safety 0) (float 0))
           (type fixnum index))
  (setf (fli:foreign-typed-aref 'sys:int32 ptr index)
        (sys:int32-1+ (fli:foreign-typed-aref 'sys:int32 
                                              ptr index)))
  ;; return ptr, since otherwise the int32 would
  ;; need to be boxed to return it
  ptr)

LispWorks User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex