r5115: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 12 Jun 2003 18:32:30 +0000 (18:32 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 12 Jun 2003 18:32:30 +0000 (18:32 +0000)
src/strings.lisp

index b4c1917a052486b358b7f5c1c757d57e30a41ff7..b5eeebe19df0e43e3898ea0749208c62632a20fe 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: strings.lisp,v 1.8 2003/06/06 21:59:18 kevin Exp $
+;;;; $Id: strings.lisp,v 1.9 2003/06/12 18:32:30 kevin Exp $
 ;;;;
 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -308,41 +308,39 @@ that LW/CMU automatically converts strings from c-calls."
     ((str (* :unsigned-char)))
   :returning :unsigned-int)
 
-#+(or lispworks (and allegro ics))
+(def-type char-ptr-def (* :unsigned-char))
+
+;;#+(or lispworks (and allegro ics))
+#+(or lispworks allegro)
 (defun fast-native-to-string (s)
   (declare (optimize (speed 3) (space 0) (safety 0) (compilation-speed 0))
           (type char-ptr-def s))
   (let* ((len (strlen s))
         (str (make-string len)))
     (declare (fixnum len)
-            (simple-string str))
-    (do ((i 0))
-       ((= i len))
-      (declare (fixnum i))
-      (setf (schar str i)
-       (code-char (uffi:deref-array s '(:array :unsigned-char) i)))
-      (incf i))
-    str))
+            (type (simple-array (signed-byte 8) (*)) str))
+    (dotimes (i len str)
+      (setf (aref str i) (uffi:deref-array s '(:array :char) i)))))
 
-#+(and allegro (not ics))
+;;#+(and allegro (not ics))
+#+ignore
 (defun fast-native-to-string (s)
-  (declare (optimize (speed 3) (space 0) (safety 0) (compilation-speed 0))
+  (declare (optimize (speed 3) (space 0) (safety 0) (compilation-speed 0) (debug 0))
           (type char-ptr-def s))
   (let* ((len (strlen s))
-        (len4 (floor len 4))
-        (str (make-string len)))
-    (declare (fixnum len)
-            (type (simple-array (signed-byte 32) (*)) str))
-    (do ((i 0))
-       ((= i len4))
+        (len4 (the fixnum (ash (the fixnum len) -2)))
+        (end4 (the fixnum (ash (the fixnum len4) 2)))
+        (remainder (the fixnum (- len end4)))
+        (str (make-string len))
+        (str4 str))
+    (declare (type fixnum len len4 end4 remainder)
+            (type (simple-array (signed-byte 32) (*)) str4)
+            (type (simple-array (signed-byte 8) (*)) str))
+    (dotimes (i len4)
       (declare (fixnum i))
-      (setf (aref (the (simple-array (signed-byte 32) (*)) str) i)
-       (uffi:deref-array s '(:array :int) i))
-       (incf i))
-    (do ((i (* 4 len4)))
-       ((= i len))
+      (setf (aref str4 i) (uffi:deref-array s '(:array :int) i)))
+    (dotimes (i remainder)
       (declare (fixnum i))
-      (setf (aref (the (simple-array (signed-byte 8) (*)) str) i)
-       (uffi:deref-array s '(:array :unsigned-char) i))
-      (incf i))
+      (setf (aref str end4) (uffi:deref-array s '(:array :char) end4))
+      (incf end4))
     str))