- (dotimes (i length)
- (setf (aref string i)
- (sb!xc:code-char (read-byte stream))))
- ;; FIXME: The classic CMU CL code to do this was
- ;; (READ-N-BYTES FILE STRING START END).
- ;; It was changed for SBCL because we needed a portable version for
- ;; bootstrapping. Benchmark the non-portable version and see whether it's
- ;; significantly better than the portable version here. If it is, then use
- ;; it as an alternate definition, protected with #-SB-XC-HOST.
- (values))
+ (declare (type (simple-array character (*)) string)
+ (type index length)
+ (optimize speed))
+ (with-fast-read-byte ((unsigned-byte 8) stream)
+ (dotimes (i length)
+ (setf (aref string i)
+ (sb!xc:code-char (fast-read-byte)))))
+ string)
+(defun read-base-string-as-bytes (stream string &optional (length (length string)))
+ (declare (type (simple-array base-char (*)) string)
+ (type index length)
+ (optimize speed))
+ (with-fast-read-byte ((unsigned-byte 8) stream)
+ (dotimes (i length)
+ (setf (aref string i)
+ (sb!xc:code-char (fast-read-byte)))))
+ string)