On 2014-08-04 16:55, Dicebot wrote:

That is exactly the problem - if `structToJson` won't be provided,
complaints are inevitable, it is too basic feature to wait for
std.serialization :(

Hmm, yeah, that's a problem.

Simplified serialization algorithm:

1) write (cast(void*) &struct)[0..struct.sizeof] to target buffer
2) write any of array content to the same buffer after the struct
3.1) if array contains structs, recursion
3.2) go back to buffer[0..struct.sizeof] slice and update array fields
to store an index in the same buffer instead of actual ptr

Simplified deserialization algorithm:

1) recursively traverse the struct and replace array index offsets with
real slices to the buffer

I see. I need to think a bit about this.

(I don't want to bother with getting copyright permissions to publish
actual code)

Fair enough. The above was quite descriptive.

I am pretty sure that this is not the only optimized serialization
approach out there that does not fit in a content-insensitive
primitive-based traversal scheme. And we won't Phobos stuff to be
blazingly fast which can lead to situation where new data module will
circumvent the std.serialization API to get more performance.

I don't like the idea of having to reimplement serialization for each data type that can be generalized.

--
/Jacob Carlborg

Reply via email to