Changeset 5520
- Timestamp:
- Nov 8, 2006, 4:15:05 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-streams.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-streams.lisp
r5427 r5520 3585 3585 (declare (fixnum count)) 3586 3586 (dotimes (i count) 3587 (stream-write-byte stream (pop list)))) 3587 (let* ((element (pop list))) 3588 (if (typep element 'character) 3589 (write-char element stream) 3590 (write-byte element stream))))) 3588 3591 3589 3592 (defmethod stream-write-list ((stream basic-binary-output-stream) … … 3591 3594 (declare (fixnum count)) 3592 3595 (dotimes (i count) 3593 (write-byte (pop list) stream))) 3596 (let* ((element (pop list))) 3597 (if (typep element 'character) 3598 (write-char element stream) 3599 (write-byte element stream))))) 3594 3600 3595 3601 (defmethod stream-read-list ((stream fundamental-binary-input-stream) … … 4917 4923 ioblock vector start total)))))) 4918 4924 4925 ;;; bivalence: we don't actually have a "bivalent stream" class; 4926 ;;; all actual (potentially) bivalent streams (sockets) include binary streams 4927 ;;; before character streams in their CPLs. That effectively means that 4928 ;;; binary-stream methods for reading and writing sequences have to 4929 ;;; handle character I/O in some cases. That may slow some things down 4930 ;;; (at least in theory), but the case where the stream's element-type 4931 ;;; matches the sequence's element-type isn't affected. 4932 (defun %ioblock-binary-stream-write-vector (ioblock vector start end) 4933 (declare (fixnum start end)) 4934 (let* ((out (ioblock-outbuf ioblock)) 4935 (buf (io-buffer-buffer out)) 4936 (written 0) 4937 (limit (io-buffer-limit out)) 4938 (total (- end start)) 4939 (buftype (typecode buf))) 4940 (declare (fixnum buftype written total limit)) 4941 (if (not (= (the fixnum (typecode vector)) buftype)) 4942 (if (typep vector 'string) 4943 (funcall (ioblock-write-simple-string-function ioblock) 4944 ioblock 4945 vector 4946 start 4947 (- end start)) 4948 (do* ((i start (1+ i)) 4949 (wbf (ioblock-write-byte-when-locked-function ioblock)) 4950 (wcf (ioblock-write-char-when-locked-function ioblock))) 4951 ((= i end)) 4952 (let ((byte (uvref vector i))) 4953 (if (characterp byte) 4954 (funcall wcf ioblock byte) 4955 (funcall wbf ioblock byte))))) 4956 (do* ((pos start (+ pos written)) 4957 (left total (- left written))) 4958 ((= left 0)) 4959 (declare (fixnum pos left)) 4960 (setf (ioblock-dirty ioblock) t) 4961 (let* ((index (io-buffer-idx out)) 4962 (count (io-buffer-count out)) 4963 (avail (- limit index))) 4964 (declare (fixnum index avail count)) 4965 (cond 4966 ((= (setq written avail) 0) 4967 (%ioblock-force-output ioblock nil)) 4968 (t 4969 (if (> written left) 4970 (setq written left)) 4971 (%copy-ivector-to-ivector 4972 vector 4973 (ioblock-elements-to-octets ioblock pos) 4974 buf 4975 (ioblock-elements-to-octets ioblock index) 4976 (ioblock-elements-to-octets ioblock written)) 4977 (setf (ioblock-dirty ioblock) t) 4978 (incf index written) 4979 (if (> index count) 4980 (setf (io-buffer-count out) index)) 4981 (setf (io-buffer-idx out) index) 4982 (if (= index limit) 4983 (%ioblock-force-output ioblock nil))))))))) 4984 4919 4985 (defmethod stream-write-vector ((stream buffered-binary-output-stream-mixin) 4920 4986 vector start end) 4921 (declare (fixnum start end))4922 4987 (with-stream-ioblock-output (ioblock stream :speedy t) 4923 (let* ((out (ioblock-outbuf ioblock)) 4924 (buf (io-buffer-buffer out)) 4925 (written 0) 4926 (limit (io-buffer-limit out)) 4927 (total (- end start)) 4928 (buftype (typecode buf))) 4929 (declare (fixnum buftype written total limit)) 4930 (if (not (= (the fixnum (typecode vector)) buftype)) 4931 (do* ((i start (1+ i)) 4932 (wbf (ioblock-write-byte-function ioblock))) 4933 ((= i end)) 4934 (let ((byte (uvref vector i))) 4935 (funcall wbf ioblock byte))) 4936 (do* ((pos start (+ pos written)) 4937 (left total (- left written))) 4938 ((= left 0)) 4939 (declare (fixnum pos left)) 4940 (setf (ioblock-dirty ioblock) t) 4941 (let* ((index (io-buffer-idx out)) 4942 (count (io-buffer-count out)) 4943 (avail (- limit index))) 4944 (declare (fixnum index avail count)) 4945 (cond 4946 ((= (setq written avail) 0) 4947 (%ioblock-force-output ioblock nil)) 4948 (t 4949 (if (> written left) 4950 (setq written left)) 4951 (%copy-ivector-to-ivector 4952 vector 4953 (ioblock-elements-to-octets ioblock pos) 4954 buf 4955 (ioblock-elements-to-octets ioblock index) 4956 (ioblock-elements-to-octets ioblock written)) 4957 (setf (ioblock-dirty ioblock) t) 4958 (incf index written) 4959 (if (> index count) 4960 (setf (io-buffer-count out) index)) 4961 (setf (io-buffer-idx out) index) 4962 (if (= index limit) 4963 (%ioblock-force-output ioblock nil)))))))))) 4988 (%ioblock-binary-stream-write-vector ioblock vector start end))) 4989 4964 4990 4965 4991 (defmethod stream-write-vector ((stream basic-binary-output-stream) … … 4968 4994 (let* ((ioblock (basic-stream-ioblock stream))) 4969 4995 (with-ioblock-output-locked (ioblock) 4970 (let* ((out (ioblock-outbuf ioblock)) 4971 (buf (io-buffer-buffer out)) 4972 (written 0) 4973 (limit (io-buffer-limit out)) 4974 (total (- end start)) 4975 (buftype (typecode buf))) 4976 (declare (fixnum buftype written total limit)) 4977 (if (not (= (the fixnum (typecode vector)) buftype)) 4978 (do* ((i start (1+ i)) 4979 (wbf (ioblock-write-byte-function ioblock))) 4980 ((= i end)) 4981 (let ((byte (uvref vector i))) 4982 (when (characterp byte) 4983 (setq byte (char-code byte))) 4984 (funcall wbf ioblock byte))) 4985 (do* ((pos start (+ pos written)) 4986 (left total (- left written))) 4987 ((= left 0)) 4988 (declare (fixnum pos left)) 4989 (setf (ioblock-dirty ioblock) t) 4990 (let* ((index (io-buffer-idx out)) 4991 (count (io-buffer-count out)) 4992 (avail (- limit index))) 4993 (declare (fixnum index avail count)) 4994 (cond 4995 ((= (setq written avail) 0) 4996 (%ioblock-force-output ioblock nil)) 4997 (t 4998 (if (> written left) 4999 (setq written left)) 5000 (%copy-ivector-to-ivector 5001 vector 5002 (ioblock-elements-to-octets ioblock pos) 5003 buf 5004 (ioblock-elements-to-octets ioblock index) 5005 (ioblock-elements-to-octets ioblock written)) 5006 (setf (ioblock-dirty ioblock) t) 5007 (incf index written) 5008 (if (> index count) 5009 (setf (io-buffer-count out) index)) 5010 (setf (io-buffer-idx out) index) 5011 (if (= index limit) 5012 (%ioblock-force-output ioblock nil))))))))))) 4996 (%ioblock-binary-stream-write-vector ioblock vector start end)))) 5013 4997 5014 4998
Note:
See TracChangeset
for help on using the changeset viewer.
