4 ms·
I'd rather use MessagePack. Clean, simple, small.
by armitron 6y ago
I'd rather use MessagePack. Clean, simple, small.
- iso8859-1 6y agoIt has worse performance though. Not zero-copy.
- ludocode 6y agoIt depends what you mean by zero-copy. It can't be traversed without parsing the structure, but strings and binary blobs can be used in-place without copying. (This is also possible with JSON even, for example with RapidJSON's in-situ parser.) This has worse performance for decoding, but far better performance for encoding. Encoding any traversible format is guaranteed to be expensive because you have to encode it inside-out, calculating the nested sizes of everything as you go. For messages that are only encoded once and read once, for example network messages, a format that is traversible in-place is a poor choice.
- Dylan16807 6y agoThat's too general. Sometimes there's [almost] nothing to calculate, so no slowdown. Sometimes the traversible format can be used as your working data structure and then encoding is a no-op.