Received: from eggs.gnu.org ([2001:4830:134:3::10]:40260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWIOG-0005N8-Qx for qemu-devel@nongnu.org; Thu, 18 Feb 2016 01:48:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWIOF-00021P-7n for qemu-devel@nongnu.org; Thu, 18 Feb 2016 01:48:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWIOF-00021G-2N for qemu-devel@nongnu.org; Thu, 18 Feb 2016 01:48:39 -0500 From: Eric Blake Date: Wed, 17 Feb 2016 23:48:25 -0700 Message-Id: <1455778109-6278-12-git-send-email-eblake@redhat.com> In-Reply-To: <1455778109-6278-1-git-send-email-eblake@redhat.com> References: <1455778109-6278-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH v11 11/15] qapi-visit: Use common idiom in gen_visit_fields_decl() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, Michael Roth We have several instances of methods that do an early exit if output is not needed, then log that output is being generated, and finally produce the output; see qapi-types.py:gen_object() and qapi-visit.py:gen_visit_implicit_struct(). The odd man out was gen_visit_fields_decl(); rearrange it to be more like the others. No semantic change or difference to generated code. Signed-off-by: Eric Blake --- v11: split out from 11/13 --- scripts/qapi-visit.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 48ebd2b..089f4c4 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -35,15 +35,14 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error ** def gen_visit_fields_decl(typ): - ret = '' - if typ.name not in struct_fields_seen: - ret += mcgen(''' + if typ.name in struct_fields_seen: + return '' + struct_fields_seen.add(typ.name) + return mcgen(''' static void visit_type_%(c_type)s_fields(Visitor *v, %(c_type)s *obj, Error **errp); ''', - c_type=typ.c_name()) - struct_fields_seen.add(typ.name) - return ret + c_type=typ.c_name()) def gen_visit_implicit_struct(typ): -- 2.5.0