qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-1.5 8/9] qom: simplify object_class_dynamic_


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH for-1.5 8/9] qom: simplify object_class_dynamic_cast, part 1
Date: Fri, 10 May 2013 12:52:22 -0500
User-agent: Notmuch/0.15.2+77~g661dcf8 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu)

Paolo Bonzini <address@hidden> writes:

> Access everything from the class.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  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) {

This won't trigger because we unconditionally strdup().  Can you add
this the bit from my patch that sets ->name appropriately?

Aurelien, can you try the resulting series with
--{enable,disable}-qom-casts?  My suspicion is that this is the primary
source of speed up.

If you can make an image available too, I can try this myself.

Regards,

Anthony Liguori

>          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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]