summaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c5
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 */