guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Implement efficient 'scm_unget_bytes' and 'unget-bytevector'


From: Ludovic Courtès
Subject: Re: [PATCH] Implement efficient 'scm_unget_bytes' and 'unget-bytevector'
Date: Sun, 07 Apr 2013 01:07:27 +0200
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.3 (gnu/linux)

Mark H Weaver <address@hidden> skribis:

> Mark H Weaver <address@hidden> 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’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]