[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-1.5?] target-ppc: Drop unnecessary dynamic c
From: |
Anthony Liguori |
Subject: |
Re: [Qemu-devel] [PATCH for-1.5?] target-ppc: Drop unnecessary dynamic cast in ppc_env_get_cpu() |
Date: |
Fri, 10 May 2013 10:06:03 -0500 |
User-agent: |
Notmuch/0.15.2+77~g661dcf8 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) |
Andreas Färber <address@hidden> writes:
> A transition from CPUPPCState to PowerPCCPU can be considered safe,
> just like PowerPCCPU::env access in the opposite direction.
>
> This should slightly improve interrupt performance.
>
> Reported-by: Anthony Liguori <address@hidden>
> Signed-off-by: Andreas Färber <address@hidden>
Another option would be to leave it and do something like:
diff --git a/qom/object.c b/qom/object.c
index 75e6aac..cba1d88 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -126,8 +126,13 @@ static TypeImpl *type_register_internal(const TypeInfo
*info)
TypeImpl *type_register(const TypeInfo *info)
{
+ TypeImpl *impl;
+
assert(info->parent);
- return type_register_internal(info);
+ impl = type_register_internal(info);
+ g_free(impl->name);
+ impl->name = info->name;
+ return impl;
}
TypeImpl *type_register_static(const TypeInfo *info)
@@ -449,10 +490,16 @@ Object *object_dynamic_cast_assert(Object *obj, const
char *typename)
ObjectClass *object_class_dynamic_cast(ObjectClass *class,
const char *typename)
{
- TypeImpl *target_type = type_get_by_name(typename);
+ TypeImpl *target_type;
TypeImpl *type = class->type;
ObjectClass *ret = NULL;
+ if (type->name == typename) {
+ return class;
+ }
+
+ target_type = type_get_by_name(typename);
+
if (!target_type) {
/* target class type unknown, so fail the cast */
return NULL;
Which makes casting an object to it's concrete class free.
Regards,
Anthony Liguori
> ---
> target-ppc/cpu-qom.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
> index eb03a00..f62181f 100644
> --- a/target-ppc/cpu-qom.h
> +++ b/target-ppc/cpu-qom.h
> @@ -91,7 +91,7 @@ typedef struct PowerPCCPU {
>
> static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
> {
> - return POWERPC_CPU(container_of(env, PowerPCCPU, env));
> + return container_of(env, PowerPCCPU, env);
> }
>
> #define ENV_GET_CPU(e) CPU(ppc_env_get_cpu(e))
> --
> 1.8.1.4