This pull request adds two new parameters that provide control over the size of the string buffer and the internal codec bytevector buffer associated with transcoded ports. It also includes changes to reduce allocation and copying in certain cases for bytevector->string, get-bytevector-all, get-bytevector-n, get-string-all, and get-string-n.
One use case for the new parameters is to allow transcoded custom binary ports to take advantage of larger buffer sizes. Previously, such ports were effectively constrained by a fixed 1024-byte internal codec buffer even if created with a large custom-port-buffer-size.
Resolved questions:
[X] Could / should we avoid allocating the ioffsets fxvector if the underlying bp does not support port-position? (Yes. Updated to avoid allocating ioffsets fxvector in this case.)
[X] Should make-codec-buffer procedure take bp and min-size instead of just bp? (For now keeping bp as the only argument.)
con: For existing codecs it will always be 4, so why pass it in. (Perhaps it could be less for latin-1-codec, but that's seems pedantic.)
con: immediate 4 is compact in the code stream
con: if users know the minimum is 4 they could skip the check in cases where they know they have something of length >= 4 available.
pro: having a min-size argument is a reminder that there is in fact a minimum length
pro: avoids ugly occurrences of "four" in documentation and 4 in user code
[X] Should I merge the two error checks on the result from make-codec-buffer into one? (Yes. Done.)
This pull request adds two new parameters that provide control over the size of the string buffer and the internal codec bytevector buffer associated with transcoded ports. It also includes changes to reduce allocation and copying in certain cases for
bytevector->string
,get-bytevector-all
,get-bytevector-n
,get-string-all
, andget-string-n
.One use case for the new parameters is to allow transcoded custom binary ports to take advantage of larger buffer sizes. Previously, such ports were effectively constrained by a fixed 1024-byte internal codec buffer even if created with a large
custom-port-buffer-size
.Resolved questions:
ioffsets
fxvector if the underlyingbp
does not supportport-position
? (Yes. Updated to avoid allocatingioffsets
fxvector in this case.)make-codec-buffer
procedure takebp
andmin-size
instead of justbp
? (For now keepingbp
as the only argument.)latin-1-codec
, but that's seems pedantic.)min-size
argument is a reminder that there is in fact a minimum lengthmake-codec-buffer
into one? (Yes. Done.)