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) |
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) | |||
1433 | return EINA_TRUE; | 1433 | return EINA_TRUE; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | const Eo *cached_isa_id = NULL; | ||
1437 | |||
1438 | static const Efl_Class *cached_klass = NULL; | ||
1439 | static Eina_Bool cached_isa = EINA_FALSE; | ||
1440 | |||
1436 | EAPI Eina_Bool | 1441 | EAPI Eina_Bool |
1437 | efl_isa(const Eo *eo_id, const Efl_Class *klass_id) | 1442 | efl_isa(const Eo *eo_id, const Efl_Class *klass_id) |
1438 | { | 1443 | { |
1444 | if (cached_isa_id == eo_id && cached_klass == klass_id) | ||
1445 | return cached_isa; | ||
1446 | |||
1439 | EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); | 1447 | EO_OBJ_POINTER_RETURN_VAL(eo_id, obj, EINA_FALSE); |
1440 | EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EINA_FALSE); | 1448 | EO_CLASS_POINTER_RETURN_VAL(klass_id, klass, EINA_FALSE); |
1441 | const op_type_funcs *func = _vtable_func_get(obj->vtable, | 1449 | const op_type_funcs *func = _vtable_func_get(obj->vtable, |
1442 | klass->base_id + klass->desc->ops.count); | 1450 | klass->base_id + klass->desc->ops.count); |
1443 | 1451 | ||
1452 | // Caching the result as we do a lot of serial efl_isa due to evas_object_image using it. | ||
1453 | cached_isa_id = eo_id; | ||
1454 | cached_klass = klass_id; | ||
1455 | |||
1444 | /* Currently implemented by reusing the LAST op id. Just marking it with | 1456 | /* Currently implemented by reusing the LAST op id. Just marking it with |
1445 | * _eo_class_isa_func. */ | 1457 | * _eo_class_isa_func. */ |
1446 | return (func && (func->func == _eo_class_isa_func)); | 1458 | cached_isa = (func && (func->func == _eo_class_isa_func)); |
1459 | |||
1460 | return cached_isa; | ||
1447 | } | 1461 | } |
1448 | 1462 | ||
1449 | EAPI Eo * | 1463 | 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) | |||
445 | #endif | 445 | #endif |
446 | } | 446 | } |
447 | 447 | ||
448 | extern const Eo *cached_isa_id; | ||
449 | |||
448 | static inline void | 450 | static inline void |
449 | _eo_id_release(const Eo_Id obj_id) | 451 | _eo_id_release(const Eo_Id obj_id) |
450 | { | 452 | { |
@@ -494,6 +496,7 @@ _eo_id_release(const Eo_Id obj_id) | |||
494 | // In case an object is destroyed, wipe out the cache | 496 | // In case an object is destroyed, wipe out the cache |
495 | cached_id = 0; | 497 | cached_id = 0; |
496 | cached_object = NULL; | 498 | cached_object = NULL; |
499 | cached_isa_id = NULL; | ||
497 | 500 | ||
498 | return; | 501 | return; |
499 | } | 502 | } |