diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-05-10 14:16:37 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-05-13 09:52:06 -0500 |
commit | 793c96b5403233fd9935c94b2af6d557c297a088 (patch) | |
tree | 544971a075a681f2c58b13097871ac54d77d74b5 /qom/object.c | |
parent | bf0fda346694db1eddecff1d74ff9f4d5eba3461 (diff) | |
download | qemu-793c96b5403233fd9935c94b2af6d557c297a088.tar.gz qemu-793c96b5403233fd9935c94b2af6d557c297a088.tar.bz2 qemu-793c96b5403233fd9935c94b2af6d557c297a088.zip |
qom: add a fast path to object_class_dynamic_cast
For leaf classes, in many cases the callbacks will simply downcast
the object back to the original class. Add this fast path to
object_class_dynamic_cast, object_dynamic_cast will inherit it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1368188203-3407-4-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qom/object.c')
-rw-r--r-- | qom/object.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c index 35f4694987..0aa0c07d70 100644 --- a/qom/object.c +++ b/qom/object.c @@ -457,7 +457,12 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, return NULL; } + /* A simple fast path that can trigger a lot for leaf classes. */ type = class->type; + if (type->name == typename) { + return class; + } + target_type = type_get_by_name(typename); if (!target_type) { /* target class type unknown, so fail the cast */ |