mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-24 12:20:20 +02:00
Optimize 'get-bytevector-some'; it may now read less than possible.
* libguile/r6rs-ports.c (scm_get_bytevector_some): Rewrite to efficiently take the contents of the read/putback buffers. In the docstring, clarify that it might not return all available bytes. * doc/ref/api-io.texi (R6RS Binary Input): Clarify that 'get-bytevector-some' might not return all available bytes. * test-suite/tests/r6rs-ports.test ("get-bytevector-some [only-some]"): Remove bogus test, which requires more than the R6RS requires.
This commit is contained in:
parent
337edc591f
commit
21bbe22a14
3 changed files with 30 additions and 83 deletions
|
@ -163,30 +163,6 @@
|
|||
(equal? (bytevector->u8-list bv)
|
||||
(map char->integer (string->list str))))))
|
||||
|
||||
(pass-if "get-bytevector-some [only-some]"
|
||||
(let* ((str "GNU Guile")
|
||||
(index 0)
|
||||
(port (make-soft-port
|
||||
(vector #f #f #f
|
||||
(lambda ()
|
||||
(if (>= index (string-length str))
|
||||
(eof-object)
|
||||
(let ((c (string-ref str index)))
|
||||
(set! index (+ index 1))
|
||||
c)))
|
||||
(lambda () #t)
|
||||
(lambda ()
|
||||
;; Number of readily available octets: falls to
|
||||
;; zero after 4 octets have been read.
|
||||
(- 4 (modulo index 5))))
|
||||
"r"))
|
||||
(bv (get-bytevector-some port)))
|
||||
(and (bytevector? bv)
|
||||
(= index 4)
|
||||
(= (bytevector-length bv) index)
|
||||
(equal? (bytevector->u8-list bv)
|
||||
(map char->integer (string->list "GNU "))))))
|
||||
|
||||
(pass-if "get-bytevector-all"
|
||||
(let* ((str "GNU Guile")
|
||||
(index 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue