David Morse | 7 Nov 2004 06:38
Picon
Favicon

Re: (setf uffi:get-slot-value) slowness in sbcl

My apologies, I was confused in my previous post.

In the following function the "declare" on line two cuts execution time 
by a factor of 1000.  Without it, it prints out a warnings similar to 
the ones in the last post per call to sdl:surface-w or sdl:surface-h 
(which are prolly just uffi:get-slot-value calls after inline expansion).

Is there some way to rewrite that declaration to use the uffi package 
instead of the nonportable sb-alien package?

(defun draw-bmp (surface screen x y)
   (declare (type (sb-alien:alien (* sdl:surface)) screen surface))
   (let ((w (sdl:surface-w surface))
	(h (sdl:surface-h surface)))
     (uffi:with-foreign-object (rect 'sdl:rect)
       (setf (sdl:rect-x rect) x
	    (sdl:rect-y rect) y
	    (sdl:rect-w rect) w
	    (sdl:rect-h rect) h)
       (sdl:blit-surface surface the-null-sdl-rect screen rect)
       (sdl:update-rect screen x y w h)
       nil)))

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
Kevin Rosenberg | 25 Nov 2004 06:59
Favicon

Re: (setf uffi:get-slot-value) slowness in sbcl

David Morse wrote:
> Is there some way to rewrite that declaration to use the uffi package 
> instead of the nonportable sb-alien package?

Yes, as an example from CLSQL's clsql-uffi.lisp:

(uffi:def-type char-ptr-def (* :unsigned-char))

(defun convert-raw-field (char-ptr types index &optional length)
  (declare (optimize (speed 3) (safety 0) (space 0))
           (type char-ptr-def char-ptr))
 ....

--

-- 
Kevin Rosenberg
kevin <at> rosenberg.net

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
Alexey Dejneka | 7 Nov 2004 10:31
X-Face
Picon
Favicon

Re: (setf uffi:get-slot-value) slowness in sbcl

Hello,

David Morse <svref <at> yahoo.com> writes:

> Is there some way to rewrite that declaration to use the uffi package
> instead of the nonportable sb-alien package?
>
> (defun draw-bmp (surface screen x y)
>    (declare (type (sb-alien:alien (* sdl:surface)) screen surface))

(uffi:def-type surface-ptr '(* sdl:surface))
...
  (declare (type surface-ptr screen surface))

--

-- 
Regards,
Alexey Dejneka

"Alas, the spheres of truth are less transparent than those of
illusion." -- L.E.J. Brouwer

-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click

Gmane