[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC v2 38/47] qapi-commands: De-duplicate output
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH RFC v2 38/47] qapi-commands: De-duplicate output marshaling functions |
Date: |
Tue, 28 Jul 2015 13:20:28 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 07/01/2015 02:22 PM, Markus Armbruster wrote:
>> gen_marshal_output() uses its parameter name only for name of the
>> generated function. Name it after the type being marshaled instead of
>> its caller, and drop duplicates.
>>
>> Saves 7 copies of qmp_marshal_output_int() in qemu-ga, and one copy of
>> qmp_marshal_output_str() in qemu-system-*.
>
> qga/qapi-generated/qga-qmp-marshal.c | 227
> +++++------------------------------
> qmp-marshal.c | 225
> +++++++++++++++-------------------
> 2 files changed, 134 insertions(+), 318 deletions(-)
>
> Most changes look like:
>
> -static void qmp_marshal_output_add_fd(AddfdInfo *ret_in, QObject
> **ret_out, Error **errp)
> +static void qmp_marshal_output_AddfdInfo(AddfdInfo *ret_in, QObject
> **ret_out, Error **errp)
> {
> Error *local_err = NULL;
> QmpOutputVisitor *mo = qmp_output_visitor_new();
> @@ -88,7 +88,7 @@ void qmp_marshal_add_fd(QDict *args, QOb
> goto out;
> }
>
> - qmp_marshal_output_add_fd(retval, ret, &local_err);
> + qmp_marshal_output_AddfdInfo(retval, ret, &local_err);
>
> coupled with wholesale deletions of functions that previously had
> identical bodies. Nice.
Exactly.
> [I suspect there might be ways to trim a LOT more code size, by
> rewriting a generic marshaller helper that is passed a varargs or
> array-of-struct list of operations to perform in order to visit an
> arbitrary object, then having each command's marshaller generated with
> the appropriate list of arguments for the generic helpers rather than
> the current approach of calling out to one marshaller helper per type -
> but exploring ideas like that is work for another series]
Oh, but generating thousands of line of repetitive code is so much fun!
Seriously: yes, that's a far better way to do it. Marshalling doesn't
have to be as fast as it could possibly be, space cost be damned.
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>> scripts/qapi-commands.py | 16 +++++++++-------
>> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> Reviewed-by: Eric Blake <address@hidden>
Thanks!
- Re: [Qemu-devel] [PATCH RFC v2 26/47] qapi-types: Convert to QAPISchemaVisitor, fixing flat unions, (continued)
[Qemu-devel] [PATCH RFC v2 32/47] qapi-event: Convert to QAPISchemaVisitor, fixing data with base, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 37/47] qapi: De-duplicate parameter list generation, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 38/47] qapi-commands: De-duplicate output marshaling functions, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 28/47] qapi-commands: Convert to QAPISchemaVisitor, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 43/47] qmp: Improve netdev_add usage example in the manual, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 42/47] qapi-schema: Fix up misleading specification of netdev_add, Markus Armbruster, 2015/07/01
[Qemu-devel] [PATCH RFC v2 46/47] qapi-introspect: Map all integer types to 'int', Markus Armbruster, 2015/07/01