From 9b65859d5e2e43fa89365224c5330e8c72ab760b Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 29 Jan 2016 06:48:43 -0700 Subject: hmp: Cache use of qapi visitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cache the visitor in a local variable instead of repeatedly calling the accessor. Signed-off-by: Eric Blake Reviewed-by: Marc-André Lureau Message-Id: <1454075341-13658-8-git-send-email-eblake@redhat.com> Signed-off-by: Markus Armbruster --- hmp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'hmp.c') diff --git a/hmp.c b/hmp.c index 6071a0b85b..6a49886138 100644 --- a/hmp.c +++ b/hmp.c @@ -1659,6 +1659,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) { @@ -1667,28 +1668,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); } -- cgit v1.2.3