1.0.3.34:
authorNathan Froyd <froydnj@cs.rice.edu>
Wed, 7 Mar 2007 02:12:56 +0000 (02:12 +0000)
committerNathan Froyd <froydnj@cs.rice.edu>
Wed, 7 Mar 2007 02:12:56 +0000 (02:12 +0000)
Make (SETF C-STRING->LISP-STRING) substantially faster and cons less.

contrib/sb-grovel/foreign-glue.lisp
version.lisp-expr

index 1a4b9e5..a35d72c 100644 (file)
@@ -280,11 +280,14 @@ deeply nested structures."
 (defun (setf c-string->lisp-string) (new-string alien &optional limit)
   (declare (string new-string))
   (let* ((upper-bound (or limit (1+ (length new-string))))
-         (last-elt (min (1- upper-bound) (length new-string))))
-    (loop for i upfrom 0 below last-elt
-          for char across new-string
-          do (setf (deref alien i) (char-code char)))
-    (setf (deref alien last-elt) 0)
+         (last-elt (min (1- upper-bound) (length new-string)))
+         (octets (sb-ext:string-to-octets new-string :end last-elt
+                                          :null-terminate t))
+         (alien-pointer (cast alien (* unsigned-char))))
+    (declare (cl:type (simple-array (unsigned-byte 8) (*)) octets))
+    (declare (cl:type sb-int:index last-elt))
+    (loop for i from 0 to last-elt
+          do (setf (deref alien-pointer i) (aref octets i)))
     (subseq new-string 0 last-elt)))
 
 (defgeneric accessors-for (struct-name element path))
index b1033d0..f96c6b1 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.3.33"
+"1.0.3.34"