From patchwork Fri Jan 29 13:48:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8163301 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 27C079F38B for ; Fri, 29 Jan 2016 13:51:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DC542038A for ; Fri, 29 Jan 2016 13:51:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B912A20221 for ; Fri, 29 Jan 2016 13:51:15 +0000 (UTC) Received: from localhost ([::1]:34229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9SF-00070E-7F for patchwork-qemu-devel@patchwork.kernel.org; Fri, 29 Jan 2016 08:51:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9QF-0003UH-17 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aP9QD-0001Hm-ON for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55511) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9QD-0001Hd-Hm for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:09 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 2B0ED8F029 for ; Fri, 29 Jan 2016 13:49:09 +0000 (UTC) Received: from red.redhat.com (ovpn-113-130.phx2.redhat.com [10.3.113.130]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0TDn5FH019157; Fri, 29 Jan 2016 08:49:08 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 29 Jan 2016 06:48:43 -0700 Message-Id: <1454075341-13658-8-git-send-email-eblake@redhat.com> In-Reply-To: <1454075341-13658-1-git-send-email-eblake@redhat.com> References: <1454075341-13658-1-git-send-email-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: marcandre.lureau@redhat.com, Paolo Bonzini , armbru@redhat.com, Luiz Capitulino Subject: [Qemu-devel] [PATCH v10 07/25] hmp: Cache use of qapi visitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cache the visitor in a local variable instead of repeatedly calling the accessor. Signed-off-by: Eric Blake Reviewed-by: Marc-André Lureau --- v10: resplit 4/37 and 5/37 by action rather than file, retain R-b. v9: no change v8: no change v7: place earlier in series, drop attempts to provide a 'kind' string, drop bogus avoidance of qmp_object_del() on error v6: new patch, split from RFC on v5 7/46 --- hmp.c | 12 +++++++----- vl.c | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hmp.c b/hmp.c index 9537f7b..6d67f9b 100644 --- a/hmp.c +++ b/hmp.c @@ -1658,6 +1658,7 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) char *id = NULL; OptsVisitor *ov; QDict *pdict; + Visitor *v; opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err); if (err) { @@ -1666,28 +1667,29 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) ov = opts_visitor_new(opts); pdict = qdict_clone_shallow(qdict); + v = opts_get_visitor(ov); - visit_start_struct(opts_get_visitor(ov), NULL, NULL, NULL, 0, &err); + visit_start_struct(v, NULL, NULL, NULL, 0, &err); if (err) { goto out_clean; } qdict_del(pdict, "qom-type"); - visit_type_str(opts_get_visitor(ov), &type, "qom-type", &err); + visit_type_str(v, &type, "qom-type", &err); if (err) { goto out_end; } qdict_del(pdict, "id"); - visit_type_str(opts_get_visitor(ov), &id, "id", &err); + visit_type_str(v, &id, "id", &err); if (err) { goto out_end; } - object_add(type, id, pdict, opts_get_visitor(ov), &err); + object_add(type, id, pdict, v, &err); out_end: - visit_end_struct(opts_get_visitor(ov), &err_end); + visit_end_struct(v, &err_end); if (!err && err_end) { qmp_object_del(id, NULL); } diff --git a/vl.c b/vl.c index b96590a..24d30f2 100644 --- a/vl.c +++ b/vl.c @@ -2827,17 +2827,19 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) OptsVisitor *ov; QDict *pdict; bool (*type_predicate)(const char *) = opaque; + Visitor *v; ov = opts_visitor_new(opts); pdict = qemu_opts_to_qdict(opts, NULL); + v = opts_get_visitor(ov); - visit_start_struct(opts_get_visitor(ov), NULL, NULL, NULL, 0, &err); + visit_start_struct(v, NULL, NULL, NULL, 0, &err); if (err) { goto out; } qdict_del(pdict, "qom-type"); - visit_type_str(opts_get_visitor(ov), &type, "qom-type", &err); + visit_type_str(v, &type, "qom-type", &err); if (err) { goto out; } @@ -2846,16 +2848,16 @@ static int object_create(void *opaque, QemuOpts *opts, Error **errp) } qdict_del(pdict, "id"); - visit_type_str(opts_get_visitor(ov), &id, "id", &err); + visit_type_str(v, &id, "id", &err); if (err) { goto out; } - object_add(type, id, pdict, opts_get_visitor(ov), &err); + object_add(type, id, pdict, v, &err); if (err) { goto out; } - visit_end_struct(opts_get_visitor(ov), &err); + visit_end_struct(v, &err); if (err) { qmp_object_del(id, NULL); }