Bin Guo <[email protected]> writes:

> json_writer_new() creates the output GString with g_string_new(NULL),
> which starts at the GLib default of 64 bytes.  Serializing typical
> QMP responses then requires multiple reallocations as the buffer
> grows -- for query-qmp-schema the GString is reallocated 12+ times.
>
> Preallocate JSON_WRITER_INITIAL_SIZE (4096) bytes.  This covers
> most QMP responses without any reallocation.  The JSONWriter is a
> short-lived object so the preallocation does not accumulate.
>
> Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> Reviewed-by: Markus Armbruster <[email protected]>
> Signed-off-by: Bin Guo <[email protected]>

Thanks!

Paolo, perhaps you can merge this together with your JSON parser
patches.


Reply via email to