fix queue manipulations in text:ports-mixin
closes PR 14871 test case included in drracket repo
This commit is contained in:
parent
54ed4f02e8
commit
df7cccdb43
|
@ -2866,8 +2866,7 @@
|
||||||
;; bytes are slower, but probably that's not the common case.
|
;; bytes are slower, but probably that's not the common case.
|
||||||
(define bytes-limit-for-a-single-go 1000)
|
(define bytes-limit-for-a-single-go 1000)
|
||||||
|
|
||||||
(define lst (at-queue->list q))
|
(let loop ([lst (at-queue->list q)] [acc null])
|
||||||
(let loop ([lst lst] [acc null])
|
|
||||||
(cond
|
(cond
|
||||||
[(null? lst)
|
[(null? lst)
|
||||||
(values (reverse acc)
|
(values (reverse acc)
|
||||||
|
@ -2885,17 +2884,16 @@
|
||||||
(define too-many-bytes? (>= (bytes-length the-bytes) bytes-limit-for-a-single-go))
|
(define too-many-bytes? (>= (bytes-length the-bytes) bytes-limit-for-a-single-go))
|
||||||
(cond
|
(cond
|
||||||
[(or (null? rest) too-many-bytes?)
|
[(or (null? rest) too-many-bytes?)
|
||||||
(define remainder-re-enqueued (list->at-queue rest))
|
|
||||||
(define-values (converted-bytes src-read-amt termination)
|
(define-values (converted-bytes src-read-amt termination)
|
||||||
(bytes-convert converter the-bytes 0 (min (bytes-length the-bytes)
|
(bytes-convert converter the-bytes 0 (min (bytes-length the-bytes)
|
||||||
bytes-limit-for-a-single-go)))
|
bytes-limit-for-a-single-go)))
|
||||||
(define new-at-queue
|
(define new-at-queue
|
||||||
(cond
|
(cond
|
||||||
[(= src-read-amt (bytes-length the-bytes))
|
[(= src-read-amt (bytes-length the-bytes))
|
||||||
remainder-re-enqueued]
|
(list->at-queue rest)]
|
||||||
[else
|
[else
|
||||||
(define leftovers (subbytes the-bytes src-read-amt (bytes-length the-bytes)))
|
(define leftovers (subbytes the-bytes src-read-amt (bytes-length the-bytes)))
|
||||||
(at-enqueue (cons leftovers key) remainder-re-enqueued)]))
|
(list->at-queue (cons (cons leftovers key) rest))]))
|
||||||
(define converted-str (bytes->string/utf-8 converted-bytes))
|
(define converted-str (bytes->string/utf-8 converted-bytes))
|
||||||
(values (reverse (cons (cons converted-str key) acc))
|
(values (reverse (cons (cons converted-str key) acc))
|
||||||
new-at-queue
|
new-at-queue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user