[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 07/25] hmp: Cache use of qapi visitor
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v10 07/25] hmp: Cache use of qapi visitor |
Date: |
Fri, 29 Jan 2016 06:48:43 -0700 |
Cache the visitor in a local variable instead of repeatedly
calling the accessor.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
---
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);
}
--
2.5.0
- [Qemu-devel] [PATCH v10 00/25] qapi visitor cleanups part 1 (post-introspection cleanups subset E), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 04/25] qapi: Dealloc visitor does not need a type_size(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 07/25] hmp: Cache use of qapi visitor,
Eric Blake <=
- [Qemu-devel] [PATCH v10 01/25] qobject: Document more shortcomings in our number handling, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 05/25] qapi: Drop dead parameter in gen_params(), Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 08/25] vl: Ensure qapi visitor properly ends struct visit, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 11/25] qapi: Track all failures between visit_start/stop, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 03/25] qapi: Drop dead dealloc visitor variable, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 13/25] qapi: Prefer type_int64 over type_int in visitors, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 14/25] qapi: Make all visitors supply uint64 callbacks, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 06/25] hmp: Drop pointless allocation during qapi visit, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 09/25] balloon: Improve use of qapi visitor, Eric Blake, 2016/01/29
- [Qemu-devel] [PATCH v10 16/25] qapi: Don't cast Enum* to int*, Eric Blake, 2016/01/29