Range interface for std.serialization

Dmitry Olshansky dmitry.olsh at gmail.com
Thu Oct 10 08:49:08 PDT 2013


10-Oct-2013 11:45, Jacob Carlborg пишет:
> On 2013-08-27 22:12, Dmitry Olshansky wrote:
>
>> Feel free to nag me on the NG and personally for any deficiency you come
>> across on the way there ;)
>
> I'm bumping this again with a new question. I'm thinking about how to
> output the data to output range. If the output range is of type ubyte[]
> how should I output serialized data looking like this:
>
> <object runtimeType="main.Foo" type="main.Foo" key="0" id="0">
>      <int key="a" id="1">3</int>
> </object>
>
> Should I output this in one chunk or in parts like this:
>
> <object runtimeType="main.Foo" type="main.Foo" key="0" id="0">
>
> Then
>
> <int key="a" id="1">3</int>
>
> Then
>
> </object>
>
[snip]

I do believe it's a very minor detail of a specific implementation of 
XML archiver.

Speaking of Archivers in general the main point is to try to avoid 
accumulating lots of data in memory if possible and put things as they go.

This however doesn't preclude the 2nd goal - outputting as much as 
possible in one go (and not 2 chunks) is preferable (1 call vs 2 calls 
to put of the output range etc) if doesn't harm memory usage (O(1) is 
OK, anything else not) and doesn't complicate archiver.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list