Changeset 5202


Ignore:
Timestamp:
Sep 13, 2006, 5:06:24 AM (18 years ago)
Author:
Gary Byers
Message:

More functions in the ioblock, some support for 8-bit encodings (like
utf-8). Not finished, but getting hard to bootstrap; need to check in
and build on all platforms before it gets even harder.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-streams.lisp

    r5192 r5202  
    373373  (decode-input-function nil)
    374374  (read-char-no-hang-function nil)
    375   (write-simple-string-function nil)
    376   (reserved0 nil)
    377   (reserved1 nil)
     375  (write-simple-string-function 'ioblock-no-char-output)
     376  (character-read-vector-function 'ioblock-no-char-input)
     377  (read-line-function 'ioblock-no-char-input)
    378378  (reserved2 nil)
    379379  (reserved3 nil))
     
    383383;;; about how streams use them.
    384384
    385 (defun ioblock-no-binary-input (ioblock)
     385(defun ioblock-no-binary-input (ioblock &rest otters)
     386  (declare (ignore otters))
    386387  (report-bad-arg (ioblock-stream ioblock) '(and binary-stream input-stream)))
    387388
    388 (defun ioblock-no-binary-output (ioblock)
     389(defun ioblock-no-binary-output (ioblock &rest others)
     390  (declare (ignore others))
    389391  (report-bad-arg (ioblock-stream ioblock) '(and binary-stream output-stream)))
    390392
    391 (defun ioblock-no-charr-input (ioblock)
     393(defun ioblock-no-charr-input (ioblock &rest others)
     394  (declare (ignore others))
    392395  (report-bad-arg (ioblock-stream ioblock) '(and character-stream input-stream)))
    393396
    394 (defun ioblock-no-char-output (ioblock)
     397(defun ioblock-no-char-output (ioblock &rest other-otters)
     398  (declare (ignore other-otters))
    395399  (report-bad-arg (ioblock-stream ioblock) '(and character-stream output-stream)))
    396400
     
    422426      (or (eq owner *current-process*)
    423427          (error "Stream ~s is private to ~s" (ioblock-stream ioblock) owner)))))
    424 
    425 
    426428
    427429
     
    494496    (aref (the (simple-array (unsigned-byte 8) (*))
    495497            (io-buffer-buffer buf)) idx)))
     498
     499(declaim (inline %ioblock-read-u16-byte))
     500
     501(defun %ioblock-read-u16-byte (ioblock)
     502  (declare (optimize (speed 3) (safety 0)))
     503  (let* ((buf (ioblock-inbuf ioblock))
     504         (idx (io-buffer-idx buf))
     505         (limit (io-buffer-count buf)))
     506    (declare (fixnum idx limit))
     507    (when (= idx limit)
     508      (unless (%ioblock-advance ioblock t)
     509        (return-from %ioblock-read-u16-byte :eof))
     510      (setq idx (io-buffer-idx buf)
     511            limit (io-buffer-count buf)))
     512    (setf (io-buffer-idx buf) (the fixnum (1+ idx)))
     513    (aref (the (simple-array (unsigned-byte 16) (*))
     514            (io-buffer-buffer buf)) idx)))
     515
     516(declaim (inline %ioblock-read-swapped-u16-byte))
     517(defun %ioblock-read-swapped-u16-byte (ioblock)
     518  (declare (optimize (speed 3) (safety 0)))
     519  (let* ((buf (ioblock-inbuf ioblock))
     520         (idx (io-buffer-idx buf))
     521         (limit (io-buffer-count buf)))
     522    (declare (fixnum idx limit))
     523    (when (= idx limit)
     524      (unless (%ioblock-advance ioblock t)
     525        (return-from %ioblock-read-swapped-u16-byte :eof))
     526      (setq idx (io-buffer-idx buf)
     527            limit (io-buffer-count buf)))
     528    (setf (io-buffer-idx buf) (the fixnum (1+ idx)))
     529    (let* ((u16 (aref (the (simple-array (unsigned-byte 16) (*))
     530            (io-buffer-buffer buf)) idx)))
     531      (declare (type (unsigned-byte 16) u16))
     532      (logand #xffff (the fixnum (logior (the fixnum (ash u16 -8))
     533                                         (the fixnum (ash u16 8))))))))
    496534
    497535
     
    635673                       #'%ioblock-read-u8-byte
    636674                       ioblock))))))))
    637  
     675
     676(defun %private-ioblock-read-u8-encoded-char (ioblock)
     677  (declare (optimize (speed 3) (safety 0)))
     678  (check-ioblock-owner ioblock)
     679  (%ioblock-read-u8-encoded-char ioblock))
     680
     681(defun %private-ioblock-read-u8-encoded-char (ioblock)
     682  (declare (optimize (speed 3) (safety 0)))
     683  (with-ioblock-input-locked (ioblock)
     684    (%ioblock-read-u8-encoded-char ioblock)))
     685
     686(declaim (inline %ioblock-read-u16-encoded-char))
     687(defun %ioblock-read-u16-encoded-char (ioblock)
     688  (declare (optimize (speed 3) (safety 0)))
     689  (let* ((ch (ioblock-untyi-char ioblock)))
     690    (if ch
     691      (prog1 ch
     692        (setf (ioblock-untyi-char ioblock) nil))
     693      (let* ((1st-unit (%ioblock-read-u16-byte ioblock)))
     694        (if (eq 1st-unit :eof)
     695          1st-unit
     696          (locally
     697              (declare (type (unsigned-byte 16) 1st-unit))
     698            (if (< 1st-unit
     699                   (the (mod #x110000) (ioblock-literal-char-code-limit ioblock)))
     700              (code-char 1st-unit)
     701              (funcall (ioblock-decode-input-function ioblock)
     702                       1st-unit
     703                       #'%ioblock-read-u16-byte
     704                       ioblock))))))))
     705
     706(defun %private-ioblock-read-u16-encoded-char (ioblock)
     707  (declare (optimize (speed 3) (safety 0)))
     708  (check-ioblock-owner ioblock)
     709  (%ioblock-read-u16-encoded-char ioblock))
     710
     711(defun %locked-ioblock-read-u16-encoded-char (ioblock)
     712  (declare (optimize (speed 3) (safety 0)))
     713  (with-ioblock-input-locked (ioblock)
     714    (%ioblock-read-u16-encoded-char ioblock)))
     715
    638716
    639717(declaim (inline %ioblock-tyi-no-hang))
     
    737815             (%ioblock-force-output ioblock nil))))))))
    738816
    739 (declaim (inline %ioblock-write-simple-string))
    740 
    741 (defun %ioblock-write-simple-string (ioblock string start-octet num-octets)
     817
     818(defun %ioblock-unencoded-write-simple-string (ioblock string start-char num-chars)
    742819  (declare (fixnum start-octet num-octets) (simple-string string))
    743820  (let* ((written 0)
     
    749826             (type (simple-array (unsigned-byte 8) (*)) buffer)
    750827             (optimize (speed 3) (safety 0)))
    751     (do* ((pos start-octet (+ pos written))
    752           (left num-octets (- left written)))
    753          ((= left 0) (setf (ioblock-charpos ioblock) col)  num-octets)
     828    (do* ((pos start-char (+ pos written))
     829          (left num-chars (- left written)))
     830         ((= left 0) (setf (ioblock-charpos ioblock) col)  num-chars)
    754831      (declare (fixnum pos left))
    755832      (setf (ioblock-dirty ioblock) t)
     
    783860
    784861
     862
    785863(defun %ioblock-eofp (ioblock)
    786864  (let* ((buf (ioblock-inbuf ioblock)))
     
    843921
    844922
     923(declaim (inline %ioblock-write-char))
    845924(defun %ioblock-write-char (ioblock char)
    846925  (declare (optimize (speed 3) (safety 0)))
     
    854933      (error "Character ~s can't be encoded on ~s" char (ioblock-stream ioblock)))))
    855934
     935(defun %private-ioblock-write-char (ioblock char)
     936  (declare (optimize (speed 3) (safety 0)))
     937  (check-ioblock-owner ioblock)
     938  (%ioblock-write-char ioblock char))
     939
     940(defun %locked-ioblock-write-char (ioblock char)
     941  (declare (optimize (speed 3) (safety 0)))
     942  (with-ioblock-input-locked (ioblock)
     943    (%ioblock-write-char ioblock char)))
     944
     945(declaim (inline %ioblock-write-u8-encoded-char))
     946(defun %ioblock-write-u8-encoded-char (ioblock char)
     947  (declare (optimize (speed 3) (safety 0)))
     948  (if (eq char #\linefeed)
     949    (setf (ioblock-charpos ioblock) 0)
     950    (incf (ioblock-charpos ioblock)))
     951  (let* ((code (char-code char)))
     952    (declare (type (mod #x110000) code))
     953    (if (< code (the fixnum (ioblock-literal-char-code-limit ioblock)))
     954      (%ioblock-write-u8-element ioblock code)
     955      (funcall (ioblock-encode-output-function ioblock)
     956               char
     957               #'%ioblock-write-u8-element
     958               ioblock))))
     959
     960(defun %private-ioblock-write-u8-encoded-char (ioblock char)
     961  (declare (optimize (speed 3) (safety 0)))
     962  (check-ioblock-owner ioblock)
     963  (%ioblock-write-u8-encoded-char ioblock char))
     964
     965(defun %locked-ioblock-write-u8-encoded-char (ioblock char)
     966  (declare (optimize (speed 3) (safety 0)))
     967  (with-ioblock-output-locked (ioblock)
     968    (%ioblock-write-u8-encoded-char ioblock char)))
     969
     970
     971(defun %ioblock-u8-encoded-write-simple-string (ioblock string start-char num-chars)
     972  (declare (fixnum start-char num-chars)
     973           (simple-base-strng string)
     974           (optimize (speed 3) (safety 0)))
     975  (do* ((i 0 (1+ i))
     976        (col (ioblock-charpos ioblock))
     977        (limit (ioblock-literal-char-code-limit ioblock))
     978        (encode-function (ioblock-encode-output-function ioblock))
     979        (start-char start-char (1+ start-char)))
     980       ((= i num-chars) (setf (ioblock-charpos ioblock) col) num-chars)
     981    (declare (fixnum i start-char limit))
     982    (let* ((char (schar string start-char))
     983           (code (char-code char)))
     984      (declare (type (mod #x110000) code))
     985      (if (eq char #\newline)
     986        (setq col 0)
     987        (incf col))
     988      (if (< code limit)
     989        (%ioblock-write-u8-element ioblock code)
     990        (funcall encode-function char #'%ioblock-write-u8-element ioblock)))))
     991
    856992(defun %ioblock-write-byte (ioblock byte)
    857993  (declare (optimize (speed 3) (safety 0)))
     
    8641000            (io-buffer-idx buf) 0)))
    8651001
    866 (defun %ioblock-read-line (ioblock)
     1002(defun %ioblock-unencoded-read-line (ioblock)
    8671003  (let* ((string "")
    8681004         (len 0)
     
    8701006         (inbuf (ioblock-inbuf ioblock))
    8711007         (buf (io-buffer-buffer inbuf))
    872          (newline (if (eq (typecode buf) target::subtag-simple-base-string)
    873                     #\newline
    874                     (char-code #\newline))))
     1008         (newline (char-code #\newline)))
    8751009    (let* ((ch (ioblock-untyi-char ioblock)))
    8761010      (when ch
    8771011        (setf (ioblock-untyi-char ioblock) nil)
    8781012        (if (eql ch #\newline)
    879           (return-from %ioblock-read-line
     1013          (return-from %ioblock-unencoded-read-line
    8801014            (values string nil))
    8811015          (progn
     
    8841018            (setf (schar string 0) ch)))))
    8851019    (loop
    886         (let* ((more 0)
    887                (idx (io-buffer-idx inbuf))
    888                (count (io-buffer-count inbuf)))
    889           (declare (fixnum idx count more))
    890           (if (= idx count)
    891             (if eof
    892               (return (values string t))
    893               (progn
    894                 (setq eof t)
    895                 (%ioblock-advance ioblock t)))
    896             (progn
    897               (setq eof nil)
    898               (let* ((pos (position newline buf :start idx :end count)))
    899                 (when pos
    900                   (locally (declare (fixnum pos))
    901                     (setf (io-buffer-idx inbuf) (the fixnum (1+ pos)))
    902                     (setq more (- pos idx))
    903                     (unless (zerop more)
    904                       (setq string
    905                             (%extend-vector
    906                              0 string (the fixnum (+ len more)))))
    907                     (%copy-u8-to-string
    908                      buf idx string len more)
    909                     (return (values string nil))))
    910                 ;; No #\newline in the buffer.  Read everything that's
    911                 ;; there into the string, and fill the buffer again.
    912                 (setf (io-buffer-idx inbuf) count)
    913                 (setq more (- count idx)
    914                       string (%extend-vector
    915                               0 string (the fixnum (+ len more))))
    916                 (%copy-u8-to-string
    917                 buf idx string len more)
    918                 (incf len more))))))))
     1020      (let* ((more 0)
     1021             (idx (io-buffer-idx inbuf))
     1022             (count (io-buffer-count inbuf)))
     1023        (declare (fixnum idx count more))
     1024        (if (= idx count)
     1025          (if eof
     1026            (return (values string t))
     1027            (progn
     1028              (setq eof t)
     1029              (%ioblock-advance ioblock t)))
     1030          (progn
     1031            (setq eof nil)
     1032            (let* ((pos (position newline buf :start idx :end count)))
     1033              (when pos
     1034                (locally (declare (fixnum pos))
     1035                  (setf (io-buffer-idx inbuf) (the fixnum (1+ pos)))
     1036                  (setq more (- pos idx))
     1037                  (unless (zerop more)
     1038                    (setq string
     1039                          (%extend-vector
     1040                           0 string (the fixnum (+ len more)))))
     1041                  (%copy-u8-to-string
     1042                   buf idx string len more)
     1043                  (return (values string nil))))
     1044              ;; No #\newline in the buffer.  Read everything that's
     1045              ;; there into the string, and fill the buffer again.
     1046              (setf (io-buffer-idx inbuf) count)
     1047              (setq more (- count idx)
     1048                    string (%extend-vector
     1049                            0 string (the fixnum (+ len more))))
     1050              (%copy-u8-to-string
     1051              buf idx string len more)
     1052              (incf len more))))))))
    9191053         
    920 (defun %ioblock-character-read-vector (ioblock vector start end)
     1054(defun %ioblock-unencoded-character-read-vector (ioblock vector start end)
    9211055  (do* ((i start)
    9221056        (in (ioblock-inbuf ioblock))
     
    10121146          (if (> avail need)
    10131147            (setq avail need))
    1014           (%copy-ivector-to-ivector inbuf idx vector i avail)
     1148          (%copy-u8-to-string inbuf idx vector i avail)
    10151149          (setf (io-buffer-idx in) (+ idx avail))
    10161150          (incf i avail)
     
    10781212
    10791213
    1080 (defun setup-ioblock-input (ioblock character-p element-type sharing)
     1214(defun setup-ioblock-input (ioblock character-p element-type sharing encoding)
    10811215  (when character-p
    1082     (setf (ioblock-read-char-function ioblock)
    1083           (case sharing
    1084             (:private '%private-ioblock-tyi)
    1085             (:lock '%locked-ioblock-tyi)
    1086             (t '%ioblock-tyi))))
     1216    (if encoding
     1217      (let* ((unit-size (character-encoding-code-unit-size encoding)))
     1218        (setf (ioblock-decode-input-function ioblock)
     1219              (character-encoding-stream-decode-function encoding))
     1220        (setf (ioblock-read-char-function ioblock)
     1221              (ecase unit-size
     1222                (8
     1223                 (case sharing
     1224                   (:private '%private-ioblock-read-u8-encoded-char)
     1225                   (:lock '%locked-ioblock-read-u8-encoded-char)
     1226                   (t '%ioblock-read-u8-encoded-char))))))
     1227      (progn
     1228        (setf (ioblock-read-char-function ioblock)
     1229              (case sharing
     1230                (:private '%private-ioblock-tyi)
     1231                (:lock '%locked-ioblock-tyi)
     1232                (t '%ioblock-tyi)))
     1233        (setf (ioblock-character-read-vector-function ioblock)
     1234              '%ioblock-unencoded-character-read-vector)
     1235        (setf (ioblock-read-line-function ioblock)
     1236              '%ioblock-unencoded-read-line))))
    10871237  (unless (or (eq element-type 'character)
    10881238              (subtypep element-type 'character))
     
    11011251                       (:lock '%locked-ioblock-read-u8-byte)
    11021252                       (t '%ioblock-read-u8-byte))))
    1103                   (t '%general-ioblock-read-byte)))))) 
     1253                  (t '%general-ioblock-read-byte))))))
     1254
     1255(defun setup-ioblock-output (ioblock character-p element-type sharing encoding)
     1256  (when character-p
     1257    (if encoding
     1258      (let* ((unit-size (character-encoding-code-unit-size encoding)))
     1259        (setf (ioblock-encode-output-function ioblock)
     1260              (character-encoding-stream-encode-function encoding))
     1261        (setf (ioblock-write-char-function ioblock)
     1262              (ecase unit-size
     1263                (8
     1264                 (case sharing
     1265                   (:private '%private-ioblock-write-u8-encoded-char)
     1266                   (:lock '%locked-ioblock-write-u8-encoded-charchar)
     1267                   (t '%ioblock-write-u8-encoded-char)))))
     1268        (setf (ioblock-write-simple-string-function ioblock)
     1269              (ecase unit-size
     1270                (8 '%ioblock-u8-encoded-write-simple-string))))
     1271      (progn
     1272        (setf (ioblock-write-simple-string-function ioblock)
     1273              '%ioblock-unencoded-write-simple-string)
     1274        (setf (ioblock-write-char-function ioblock)
     1275              (case sharing
     1276                (:private '%private-ioblock-write-char)
     1277                (:lock '%locked-ioblock-write-char)
     1278                (t '%ioblock-write-char)))))))
     1279
     1280(defun buffer-element-type-for-character-encoding (encoding)
     1281  (if encoding
     1282    (ecase (character-encoding-code-unit-size encoding)
     1283      (8 '(unsigned-byte 8))
     1284      (16 '(unsigned-byte 16))
     1285      (32 '(unsigned-byte 32)))
     1286    '(unsigned-byte 8)))
    11041287
    11051288(defun init-stream-ioblock (stream
     
    11221305                            (sharing :private)
    11231306                            character-p
     1307                            encoding
    11241308                            &allow-other-keys)
    11251309  (declare (ignorable element-shift))
     1310  (when encoding
     1311    (unless (typep encoding 'character-encoding)
     1312      (setq encoding (get-character-encoding encoding)))
     1313    (if (eq encoding (get-character-encoding nil))
     1314      (setq encoding nil)))
    11261315  (when sharing
    11271316    (unless (or (eq sharing :private)
     
    11371326    (when (eq sharing :private)
    11381327      (setf (ioblock-owner ioblock) *current-process*))
     1328    (setf (ioblock-encoding ioblock) encoding)
     1329    (setf (ioblock-literal-char-code-limit ioblock)
     1330          (if encoding
     1331            (character-encoding-literal-char-code-limit encoding)
     1332            256))
    11391333    (when insize
    11401334      (unless (ioblock-inbuf ioblock)
    11411335        (multiple-value-bind (buffer ptr in-size-in-octets)
    1142             (make-heap-ivector insize (if character-p '(unsigned-byte 8) element-type))
     1336            (make-heap-ivector insize
     1337                               (if character-p
     1338                                 (buffer-element-type-for-character-encoding encoding)
     1339                                 element-type))
    11431340          (setf (ioblock-inbuf ioblock)
    11441341                (make-io-buffer :buffer buffer
     
    11481345          (when (eq sharing :lock)
    11491346            (setf (ioblock-inbuf-lock ioblock) (make-lock)))
    1150           (setup-ioblock-input ioblock character-p element-type sharing)
     1347          (setup-ioblock-input ioblock character-p element-type sharing encoding)
    11511348          (setf (ioblock-element-shift ioblock) (max 0 (ceiling (log  (/ in-size-in-octets insize) 2))))
    11521349          )))
     
    11611358        (unless (ioblock-outbuf ioblock)
    11621359          (multiple-value-bind (buffer ptr out-size-in-octets)
    1163               (make-heap-ivector outsize (if character-p '(unsigned-byte 8) element-type))
     1360              (make-heap-ivector outsize
     1361                                 (if character-p
     1362                                   (buffer-element-type-for-character-encoding encoding)
     1363                                   element-type))
    11641364            (setf (ioblock-outbuf ioblock)
    11651365                  (make-io-buffer :buffer buffer
     
    11721372            (setf (ioblock-element-shift ioblock) (max 0 (ceiling (log (/ out-size-in-octets outsize) 2))))
    11731373            ))))
     1374    (when (or share-buffers-p outsize)
     1375      (setup-ioblock-output ioblock character-p element-type sharing encoding))
    11741376    (when element-type
    11751377      (setf (ioblock-element-type ioblock) element-type))
     
    12351437                          (character-p (or (eq element-type 'character)
    12361438                                           (subtypep element-type 'character)))
    1237                           (basic nil))
     1439                          (basic nil)
     1440                          encoding)
    12381441  (when basic
    12391442    (setq class (map-to-basic-stream-class-name class))
     
    12601463                         :close-function 'fd-stream-close
    12611464                         :sharing sharing
    1262                          :character-p character-p)))
     1465                         :character-p character-p
     1466                         :encoding encoding)))
    12631467 
    12641468;;;  Fundamental streams.
     
    16251829    (let* ((ioblock (basic-stream-ioblock stream)))
    16261830      (with-ioblock-input-locked (ioblock)
    1627         (%ioblock-character-read-vector ioblock vector start end)))))
     1831        (funcall (ioblock-character-read-vector-function ioblock)
     1832                 ioblock vector start end)))))
    16281833
    16291834(defmethod stream-read-line ((stream basic-character-input-stream))
    16301835  (let* ((ioblock (basic-stream-ioblock stream)))
    16311836    (with-ioblock-input-locked (ioblock)
    1632       (%ioblock-read-line ioblock))))
     1837      (funcall (ioblock-read-line-function ioblock) ioblock))))
    16331838
    16341839                             
     
    24622667
    24632668(defmethod stream-write-char ((stream buffered-character-output-stream-mixin) char)
    2464   (with-stream-ioblock-output (ioblock stream :speedy t)
    2465     (%ioblock-write-char ioblock char)))
     2669  (let* ((ioblock (stream-ioblock stream t)))
     2670    (funcall (ioblock-write-char-function ioblock) ioblock char)))
    24662671
    24672672(defmethod stream-write-char ((stream basic-character-output-stream) char)
    24682673  (let* ((ioblock (basic-stream-ioblock stream)))
    2469     (with-ioblock-output-locked (ioblock)
    2470       (%ioblock-write-char ioblock char))))
     2674    (funcall (ioblock-write-char-function ioblock) ioblock char)))
    24712675
    24722676
     
    25352739      nil)))
    25362740
    2537 (defun %ioblock-write-general-string (ioblock string start end)
    2538   (setq end (check-sequence-bounds string start end))
    2539   (locally (declare (fixnum start end))
    2540     (multiple-value-bind (arr offset)
    2541         (if (typep string 'simple-string)
    2542           (values string 0)
    2543           (array-data-and-offset (require-type string 'string)))
    2544       (unless (eql 0 offset)
    2545         (incf start offset)
    2546         (incf end offset))
    2547       (%ioblock-write-simple-string ioblock arr start (the fixnum (- end start))))))
     2741
    25482742 
    25492743(defmethod stream-write-string ((stream buffered-character-output-stream-mixin)
     
    25532747    (if (and (typep string 'simple-string)
    25542748             (not start-p))
    2555       (%ioblock-write-simple-string ioblock string 0 (length string))
    2556       (%ioblock-write-general-string ioblock string start end))))
     2749      (funcall (ioblock-write-simple-string-function ioblock)
     2750               ioblock string 0 (length string))
     2751      (progn
     2752        (setq end (check-sequence-bounds string start end))
     2753        (locally (declare (fixnum start end))
     2754          (multiple-value-bind (arr offset)
     2755              (if (typep string 'simple-string)
     2756                (values string 0)
     2757                (array-data-and-offset (require-type string 'string)))
     2758            (unless (eql 0 offset)
     2759              (incf start offset)
     2760              (incf end offset))
     2761            (funcall (ioblock-write-simple-string-function ioblock)
     2762                     ioblock arr start (the fixnum (- end start))))))))
     2763  string)
    25572764
    25582765(defmethod stream-write-string ((stream basic-character-output-stream)
     
    25612768  (let* ((ioblock (basic-stream-ioblock stream)))
    25622769    (with-ioblock-output-locked (ioblock)
    2563     (if (and (typep string 'simple-string)
    2564              (not start-p))
    2565       (%ioblock-write-simple-string ioblock string 0 (length string))
    2566       (%ioblock-write-general-string ioblock string start end)))))
     2770      (if (and (typep string 'simple-string)
     2771               (not start-p))
     2772        (funcall (ioblock-write-simple-string-function ioblock)
     2773                 ioblock string 0 (length string))
     2774        (progn
     2775          (setq end (check-sequence-bounds string start end))
     2776          (locally (declare (fixnum start end))
     2777            (multiple-value-bind (arr offset)
     2778                (if (typep string 'simple-string)
     2779                  (values string 0)
     2780                  (array-data-and-offset (require-type string 'string)))
     2781              (unless (eql 0 offset)
     2782                (incf start offset)
     2783                (incf end offset))
     2784              (funcall (ioblock-write-simple-string-function ioblock)
     2785                       ioblock arr start (the fixnum (- end start)))))))))
     2786  string)
    25672787
    25682788
     
    27022922                 (%ioblock-force-output ioblock nil)))))))))))
    27032923
    2704 (defmethod stream-read-vector ((stream basic-character-input-stream)
    2705                                vector start end)
    2706   (declare (fixnum start end))
    2707   (if (not (typep vector 'simple-base-string))
    2708     (call-next-method)
    2709     (let* ((ioblock (basic-stream-ioblock stream)))
    2710       (with-ioblock-input-locked (ioblock)
    2711         (%ioblock-character-read-vector ioblock vector start end)))))
     2924
    27122925
    27132926(defmethod stream-read-vector ((stream basic-binary-input-stream)
     
    27262939    (call-next-method)
    27272940    (with-stream-ioblock-input (ioblock stream :speedy t)
    2728       (%ioblock-character-read-vector ioblock vector start end))))
     2941      (funcall (ioblock-character-read-vector-function ioblock)
     2942               ioblock vector start end))))
    27292943
    27302944
     
    29883202(defmethod stream-read-line ((s buffered-stream-mixin))
    29893203   (with-stream-ioblock-input (ioblock s :speedy t)
    2990      (%ioblock-read-line ioblock)))
     3204     (funcall (ioblock-read-line-function ioblock) ioblock)))
    29913205
    29923206(defmethod stream-clear-input ((s fd-input-stream))
Note: See TracChangeset for help on using the changeset viewer.