Changeset 5064


Ignore:
Timestamp:
Sep 2, 2006, 9:57:41 AM (18 years ago)
Author:
Gary Byers
Message:

%COPY-U8-TO-STRING, %COPY-STRING-TO-U8: new, to avoid %COPY-IVECTOR-TO-IVECTOR
when strings are involved.

%STR-FROM-PTR: take dest string as optional arg, don't assume 8-bit chars.

%GET-CSTRING: change type decl, use %GET-UNSIGNED-BYTE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-0/l0-misc.lisp

    r4884 r5064  
    2525      (return tail))))
    2626
    27 
     27(defun %copy-u8-to-string (u8-vector source-idx string dest-idx n)
     28  (declare (optimize (speed 3) (safety 0))
     29           (fixnum source-idx dest-idx n)
     30           (type (simple-array (unsigned-byte 8) (*)) u8-vector)
     31           (simple-base-string string))
     32  (do* ((i 0 (1+ i)))
     33       ((= i n) string)
     34    (declare (fixnum i))
     35    (setf (%scharcode string dest-idx) (aref u8-vector source-idx))
     36    (incf source-idx)
     37    (incf dest-idx)))
     38
     39(defun %copy-string-to-u8 (string source-idx u8-vector dest-idx n)
     40  (declare (optimize (speed 3) (safety 0))
     41           (fixnum source-idx dest-idx n)
     42           (type (simple-array (unsigned-byte 8) (*)) u8-vector)
     43           (simple-base-string string))
     44  (do* ((i 0 (1+ i)))
     45       ((= i n) u8-vector)
     46    (declare (fixnum i))
     47    (setf (aref u8-vector dest-idx) (%scharcode string source-idx))
     48    (incf source-idx)
     49    (incf dest-idx)))
     50   
     51       
    2852
    2953
     
    348372     (uvsize seq))))
    349373
    350 (defun %str-from-ptr (pointer len)
    351   (%copy-ptr-to-ivector pointer 0 (make-string len :element-type 'base-char) 0 len))
     374(defun %str-from-ptr (pointer len &optional (dest (make-string len)))
     375  (declare (fixnum len)
     376           (optimize (speed 3) (safety 0)))
     377  (dotimes (i len dest)
     378    (setf (%scharcode dest i) (%get-unsigned-byte pointer i))))
    352379
    353380(defun %get-cstring (pointer)
    354381  (do* ((end 0 (1+ end)))
    355        ((zerop (the fixnum (%get-byte pointer end)))
     382       ((zerop (the (unsigned-byte 8) (%get-unsigned-byte pointer end)))
    356383        (%str-from-ptr pointer end))
    357384    (declare (fixnum end))))
Note: See TracChangeset for help on using the changeset viewer.