efficient input range buffering

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Oct 2 10:15:29 PDT 2011


On 02.10.2011 21:06, Robert Jacques wrote:
> On Sun, 02 Oct 2011 10:46:38 -0400, Dmitry Olshansky
> <dmitry.olsh at gmail.com> wrote:
>
>> On 02.10.2011 18:12, Martin Nowak wrote:
>>> I've written a wrapper to promote input ranges to buffered forward
>>> ranges.
>>> It allows to write range agnostic lexers/parsers with infinite
>>> lookahead.
>>>
>>> Buffering is done through a singly linked list of memory blocks that are
>>> reference counted.
>>> Each saved range holds a reference to all future blocks.
>>> Blocks are recycled when being no longer used.
>>>
>>> https://gist.github.com/1257196
>>>
>>
>> Like it, but one thing catches my eye - why use GC for blocks when the
>> whole thing is already refcounted? Straight malloc/free would be a
>> better fit. Certainly it may use an allocator when we have them.
>
> Consider that the elements could contain pointers, etc.

Mmh.. You are right, I was thinking I/O as soon as I seen line about 
lexers/parsers. Though it could be an optimization if hasIndirections!T 
is false.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list