mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
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>
This commit is contained in:
parent
845b54efaf
commit
b801e3cb2a
3 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue