Removing -partial bytevector variants.

This commit is contained in:
Alex Shinn 2012-10-14 22:26:27 +09:00
parent 08a5a2e0e8
commit 993e690891
2 changed files with 14 additions and 14 deletions

View file

@ -13,7 +13,7 @@
(export (export
* + - ... / < <= = => > >= _ abs and append apply assoc assq assv begin * + - ... / < <= = => > >= _ abs and append apply assoc assq assv begin
binary-port? boolean? boolean=? bytevector-copy bytevector-copy! binary-port? boolean? boolean=? bytevector-copy bytevector-copy!
bytevector-copy-partial bytevector-length bytevector-length
bytevector-u8-ref bytevector-u8-set! bytevector? caar cadr bytevector-u8-ref bytevector-u8-set! bytevector? caar cadr
call-with-current-continuation call-with-port call-with-values call-with-current-continuation call-with-port call-with-values
call/cc car case cdr cdar cddr ceiling char->integer call/cc car case cdr cdar cddr ceiling char->integer
@ -45,7 +45,7 @@
unquote-splicing utf8->string values vector vector->list vector->string unquote-splicing utf8->string values vector vector->list vector->string
vector-copy vector-copy! vector-fill! vector-for-each vector-length vector-copy vector-copy! vector-fill! vector-for-each vector-length
vector-map vector-ref vector-set! vector? when with-exception-handler vector-map vector-ref vector-set! vector? when with-exception-handler
write-bytevector write-char write-partial-bytevector write-u8 zero?) write-bytevector write-char write-u8 zero?)
(include "define-values.scm" (include "define-values.scm"
"extras.scm" "extras.scm"
"misc-macros.scm")) "misc-macros.scm"))

View file

@ -72,12 +72,14 @@
(bytevector-u8-set! vec (+ i start) (bytevector-u8-ref res i)))))))) (bytevector-u8-set! vec (+ i start) (bytevector-u8-ref res i))))))))
(define (write-bytevector vec . o) (define (write-bytevector vec . o)
(write-string (utf8->string vec) (bytevector-length vec) (if (pair? o) (car o) (current-output-port)))) (let* ((out (if (pair? o) (car o) (current-output-port)))
(o (if (pair? o) (cdr o) '()))
(define (write-partial-bytevector vec start end . o) (start (if (pair? o) (car o) 0))
(if (zero? start) (o (if (pair? o) (cdr o) '()))
(apply write-bytevector vec end o) (end (if (pair? o) (car o) (bytevector-length vec))))
(apply write-bytevector (bytevector-copy-partial vec start end) o))) (do ((i start (+ i 1)))
((>= i end))
(write-u8 (bytevector-u8-ref vec i) out))))
(define (make-list n . o) (define (make-list n . o)
(let ((init (and (pair? o) (car o)))) (let ((init (and (pair? o) (car o))))
@ -128,11 +130,6 @@
(define (string->vector vec) (define (string->vector vec)
(list->vector (string->list vec))) (list->vector (string->list vec)))
(define (bytevector-copy bv)
(let ((res (make-bytevector (bytevector-length bv))))
(bytevector-copy! bv res)
res))
(define (bytevector-copy! to at from . o) (define (bytevector-copy! to at from . o)
(let ((start (if (pair? o) (car o) 0)) (let ((start (if (pair? o) (car o) 0))
(end (if (and (pair? o) (pair? (cdr o))) (end (if (and (pair? o) (pair? (cdr o)))
@ -142,7 +139,10 @@
((>= j end)) ((>= j end))
(bytevector-u8-set! to i (bytevector-u8-ref from j))))) (bytevector-u8-set! to i (bytevector-u8-ref from j)))))
(define bytevector-copy-partial subbytes) (define (bytevector-copy vec . o)
(if (null? o)
(subbytes vec 0)
(apply subbytes vec o)))
;; Never use this! ;; Never use this!
(define (string-copy! to at from . o) (define (string-copy! to at from . o)