copy only reference rather duplicate a string in appender!string

Marc jckj33 at gmail.com
Tue Dec 26 15:37:12 UTC 2017


I do build a string by coping large parts of diffrent buffers, 
all those buffers live after the functional call, so rather than 
duplicate those string I'd like to copy only references to those 
parts rather duplicate every string. I combined appender!string, 
assumeUnique() and array slices. Something like this:

> auto buffer = appender!string;
> auto list = cycle(buffers);
> while(bufferIsFilled) {
>   char[] buffer = get_buffer(); // pop a buffer from circular 
> buffer
>   int s = get_buffer_size(x); // determine which part of that 
> buffer we need
>   buffer.put(assumeUnique(buf[0 .. s])); // and here's my 
> question
> }
> return buffer.data;


More information about the Digitalmars-d-learn mailing list