efficient input range buffering

Robert Jacques sandford at jhu.edu
Sun Oct 2 10:06:52 PDT 2011


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.


More information about the Digitalmars-d mailing list