summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-11-06 18:34:50 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-11-06 19:21:19 +0900
commit0ec2ced815134915f60b2c6adec1ccf9562b3938 (patch)
tree16b0d2b6c9158c714d336d58cbb208adfe27daa4
parent6d76943c1ef6d379d91230387db45a52c4bb0e1d (diff)
downloadefl-devs/jpeg/evasgl.tar.gz
Eina: Micro-optimize eina_main_loop_isdevs/jpeg/evasgl
Since this is called a crazy number of times with Eo, it would be good to have the fastest solution possible. pthread_equal costs about twice as much as pthread_self() even though it can safely be emulated with == Valgrind reports a drop from ~3.2% to ~1.5% of all instructions.
-rw-r--r--src/lib/eina/eina_main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/eina/eina_main.c b/src/lib/eina/eina_main.c
index 1daa795e87..ffb017767e 100644
--- a/src/lib/eina/eina_main.c
+++ b/src/lib/eina/eina_main.c
@@ -416,7 +416,13 @@ EAPI Eina_Bool
eina_main_loop_is(void)
{
#ifdef EFL_HAVE_THREADS
- if (pthread_equal(_eina_main_loop, pthread_self()))
+# ifdef __GNUC__
+ /* pthread_self() can't be optimized, it's a single asm "movl" */
+ if (__builtin_types_compatible_p(pthread_t, unsigned long int))
+ return (pthread_self() == _eina_main_loop);
+ else
+# endif
+ if (pthread_equal(_eina_main_loop, pthread_self()))
return EINA_TRUE;
#endif
return EINA_FALSE;