diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2024-10-29 10:45:51 +0100 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2024-10-31 18:28:32 +0100 |
| commit | b801e3cb2a7fd631a219222a8cbe9d554c906070 (patch) | |
| tree | 6ac9a4df0938700c017b91196f971a667aeef24f /hw/core/qdev.c | |
| parent | 845b54efafa5c28040570dcb6d7f8f84d23e37f3 (diff) | |
| download | focaccia-qemu-b801e3cb2a7fd631a219222a8cbe9d554c906070.tar.gz focaccia-qemu-b801e3cb2a7fd631a219222a8cbe9d554c906070.zip | |
qom: use object_new_with_class when possible
A small optimization/code simplification, that also makes it clear that we won't look for a type in a not-loaded-yet module---the module will have been loaded by a call to module_object_class_by_name(), if present. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core/qdev.c')
| -rw-r--r-- | hw/core/qdev.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index db36f54d91..2f740fa55e 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -167,10 +167,11 @@ DeviceState *qdev_new(const char *name) DeviceState *qdev_try_new(const char *name) { - if (!module_object_class_by_name(name)) { + ObjectClass *oc = module_object_class_by_name(name); + if (!oc) { return NULL; } - return DEVICE(object_new(name)); + return DEVICE(object_new_with_class(oc)); } static QTAILQ_HEAD(, DeviceListener) device_listeners |