Mark H Weaver <m...@netris.org> skribis: > Mark H Weaver <m...@netris.org> writes: > >> I discovered that 'scm_unget_byte' is kind of dumb. It puts the bytes >> at the beginning of the pushback buffer instead of the end. This means >> that every time you unget a byte, it has to shift up the existing >> contents of the buffer, so ungetting N bytes takes O(N^2) time. >> >> This patch implements a function 'scm_unget_bytes' that enables large >> buffers to be unread efficiently. It keeps the bytes at the end of the >> buffer instead of the beginning, but it can cope if some external code >> manipulates the pushback buffer by hand and puts the bytes at the >> beginning. > > Here's an improved patch that also exports 'unget-bytevector' from > (ice-9 binary-ports).
LGTM. > I've used it to unget 15 megabytes, and it was quite fast. > Unfortunately, I'm at a bit of a loss of where to document it in the > manual. What about adding a sentence to mention (ice-9 bytevectors) under “Bytevectors”, and then ‘unget-bytevector’ under “R6RS Binary Input”? Ludo’.