diff options
author | Cedric BAIL <cedric@osg.samsung.com> | 2016-08-26 12:04:23 -0700 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2016-08-26 12:14:14 -0700 |
commit | aaa0e962b75174b6dca90816b11a4e05c2985a9e (patch) | |
tree | ffbce2e9e843c8ed756f77dae26742f919ee1364 | |
parent | 93a706a947cd2d6ef80f8704f4e23737fea1258f (diff) | |
download | efl-aaa0e962b75174b6dca90816b11a4e05c2985a9e.tar.gz |
eo: speedup efl_isa by 50%.
Most of our use case of efl_isa is related to legacy Evas_Object_Image API,
that check the isa of the same object again and again. Caching help.
-rw-r--r-- | src/lib/eo/eo.c | 16 | ||||
-rw-r--r-- | src/lib/eo/eo_ptr_indirection.x | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c index b5354c020e..f8eaaf4903 100644 --- a/src/lib/eo/eo.c +++ b/src/lib/eo/eo.c @@ -1433,17 +1433,31 @@ efl_object_override(Eo *eo_id, const Efl_Object_Ops *ops) return EINA_TRUE; } +const Eo *cached_isa_id = NULL; + +static const Efl_Class *cached_klass = NULL; +static Eina_Bool cached_isa = EINA_FALSE; + EAPI Eina_Bool efl_isa(const Eo *eo_id, const Efl_Class *klass_id) { + if (cached_isa_id == eo_id && cached_klass == klass_id) + return cached_isa; + EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EINA_FALSE); const op_type_funcs *func = _vtable_func_get(obj->vtable, klass->base_id + klass->desc->ops.count); + // Caching the result as we do a lot of serial efl_isa due to evas_object_image using it. + cached_isa_id = eo_id; + cached_klass = klass_id; + /* Currently implemented by reusing the LAST op id. Just marking it with * _eo_class_isa_func. */ - return (func && (func->func == _eo_class_isa_func)); + cached_isa = (func && (func->func == _eo_class_isa_func)); + + return cached_isa; } EAPI Eo * diff --git a/src/lib/eo/eo_ptr_indirection.x b/src/lib/eo/eo_ptr_indirection.x index cae59a4469..2f95e642bc 100644 --- a/src/lib/eo/eo_ptr_indirection.x +++ b/src/lib/eo/eo_ptr_indirection.x @@ -445,6 +445,8 @@ _eo_id_allocate(const _Eo_Object *obj) #endif } +extern const Eo *cached_isa_id; + static inline void _eo_id_release(const Eo_Id obj_id) { @@ -494,6 +496,7 @@ _eo_id_release(const Eo_Id obj_id) // In case an object is destroyed, wipe out the cache cached_id = 0; cached_object = NULL; + cached_isa_id = NULL; return; } |