Eina: Micro-optimize eina_main_loop_is

This is useful when Eo calls it to get the current frame stack.
This improves the performance of this function by ~50% which meant
from ~3% total CPU time to ~1.5% CPU time (if called at each eo_do).

Now this patch is a bit irrelevant since eo uses __thread instead.

This optimization is still useful for evas_eglGetCurrentXXX.
This commit is contained in:
Jean-Philippe Andre 2015-11-06 18:34:50 +09:00
parent 3505650046
commit d99ca361de
1 changed files with 7 additions and 1 deletions

View File

@ -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;