From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UamG2-00046v-KH for qemu-devel@nongnu.org; Fri, 10 May 2013 08:17:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UamG1-0007mM-2y for qemu-devel@nongnu.org; Fri, 10 May 2013 08:17:06 -0400 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:35867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UamG0-0007lh-Sj for qemu-devel@nongnu.org; Fri, 10 May 2013 08:17:04 -0400 Received: by mail-wg0-f46.google.com with SMTP id n12so3897209wgh.1 for ; Fri, 10 May 2013 05:17:04 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 10 May 2013 14:16:42 +0200 Message-Id: <1368188203-3407-9-git-send-email-pbonzini@redhat.com> In-Reply-To: <1368188203-3407-1-git-send-email-pbonzini@redhat.com> References: <1368188203-3407-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH for-1.5 8/9] qom: simplify object_class_dynamic_cast, part 1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Andreas Faerber , Aurelien Jarno , mst@redhat.com Access everything from the class. Signed-off-by: Paolo Bonzini --- qom/object.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/qom/object.c b/qom/object.c index f5f416b..f82f12c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -457,15 +457,13 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, { ObjectClass *ret = NULL; TypeImpl *target_type; - TypeImpl *type; if (!class) { return NULL; } /* A simple fast path that can trigger a lot for leaf classes. */ - type = class->type; - if (type->name == typename) { + if (class->type->name == typename) { return class; } @@ -475,7 +473,7 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, return NULL; } - if (type->class->interfaces && + if (class->interfaces && type_is_ancestor(target_type, type_interface)) { int found = 0; GSList *i; @@ -493,7 +491,7 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, if (found > 1) { ret = NULL; } - } else if (type_is_ancestor(type, target_type)) { + } else if (type_is_ancestor(class->type, target_type)) { ret = class; } -- 1.8.1.4