summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-15 18:03:27 +0100
committerTom Hacohen <tom@stosb.com>2015-11-09 11:43:04 +0000
commitf28f6ecbfa7a19c0425a33edd6a72d7bc8293e1e (patch)
tree149751d557c65fde8fb3c6415424175692f3000f
parent9686e44b927744afa6b230c31cf64cf005e45484 (diff)
Eo: Move op resolve check to where it belongs (out of hot path).
It was put in the wrong place. It should abort early if it detects we can't resolve, and shouldn't check it if we already know it's OK.
-rw-r--r--src/lib/eo/Eo.h7
-rw-r--r--src/lib/eo/eo.c5
-rw-r--r--src/tests/eo/suite/eo_test_call_errors.c2
3 files changed, 11 insertions, 3 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 3e5ad42f7b..fc450c22fd 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -484,8 +484,11 @@ typedef struct _Eo_Call_Cache
484#define EO_FUNC_COMMON_OP(Name, DefRet) \ 484#define EO_FUNC_COMMON_OP(Name, DefRet) \
485 static Eo_Call_Cache ___cache; /* static 0 by default */ \ 485 static Eo_Call_Cache ___cache; /* static 0 by default */ \
486 Eo_Op_Call_Data ___call; \ 486 Eo_Op_Call_Data ___call; \
487 if (___cache.op == EO_NOOP) \ 487 if (EINA_UNLIKELY(___cache.op == EO_NOOP)) \
488 ___cache.op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name)); \ 488 { \
489 ___cache.op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name)); \
490 if (___cache.op == EO_NOOP) return DefRet; \
491 } \
489 if (!_eo_call_resolve(#Name, &___call, &___cache, \ 492 if (!_eo_call_resolve(#Name, &___call, &___cache, \
490 __FILE__, __LINE__)) return DefRet; \ 493 __FILE__, __LINE__)) return DefRet; \
491 _Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; \ 494 _Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; \
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 2742dc66fc..1d046c2d17 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -743,6 +743,11 @@ _eo_api_op_id_get(const void *api_func)
743#endif 743#endif
744 eina_spinlock_release(&_ops_storage_lock); 744 eina_spinlock_release(&_ops_storage_lock);
745 745
746 if (op == EO_NOOP)
747 {
748 ERR("Unable to resolve op for api func %p", api_func);
749 }
750
746 return op; 751 return op;
747} 752}
748 753
diff --git a/src/tests/eo/suite/eo_test_call_errors.c b/src/tests/eo/suite/eo_test_call_errors.c
index e6a9883d6c..5a03cd83b7 100644
--- a/src/tests/eo/suite/eo_test_call_errors.c
+++ b/src/tests/eo/suite/eo_test_call_errors.c
@@ -37,7 +37,7 @@ START_TEST(eo_api_not_implemented_call)
37 Eo *obj = eo_add(SIMPLE_CLASS, NULL); 37 Eo *obj = eo_add(SIMPLE_CLASS, NULL);
38 fail_if(!obj); 38 fail_if(!obj);
39 39
40 TEST_EO_ERROR("_eo_call_resolve", "%s:%d: unable to resolve %s api func '%s' in class '%s'."); 40 TEST_EO_ERROR("_eo_api_op_id_get", "Unable to resolve op for api func %p");
41 eo_do(obj, simple_no_implementation()); 41 eo_do(obj, simple_no_implementation());
42 fail_unless(ctx.did); 42 fail_unless(ctx.did);
43 43