gthread: use inline keyword for _get_impl() functions

Give compiler a hint that these should be inlined,
which doesn't seem to happen by default with -O2.
Yields 5% speedup in artificial benchmarks, and
1% speedup in a real-world test case doing a lot
of mutex locking and unlocking.

https://bugzilla.gnome.org/show_bug.cgi?id=730807
This commit is contained in:
Tim-Philipp Müller 2014-05-31 14:54:08 +01:00 committed by Ryan Lortie
parent db0e43d25a
commit 256305dea5

View File

@ -114,7 +114,7 @@ g_mutex_impl_free (pthread_mutex_t *mutex)
free (mutex); free (mutex);
} }
static pthread_mutex_t * static inline pthread_mutex_t *
g_mutex_get_impl (GMutex *mutex) g_mutex_get_impl (GMutex *mutex)
{ {
pthread_mutex_t *impl = g_atomic_pointer_get (&mutex->p); pthread_mutex_t *impl = g_atomic_pointer_get (&mutex->p);
@ -285,7 +285,7 @@ g_rec_mutex_impl_free (pthread_mutex_t *mutex)
free (mutex); free (mutex);
} }
static pthread_mutex_t * static inline pthread_mutex_t *
g_rec_mutex_get_impl (GRecMutex *rec_mutex) g_rec_mutex_get_impl (GRecMutex *rec_mutex)
{ {
pthread_mutex_t *impl = g_atomic_pointer_get (&rec_mutex->p); pthread_mutex_t *impl = g_atomic_pointer_get (&rec_mutex->p);
@ -445,7 +445,7 @@ g_rw_lock_impl_free (pthread_rwlock_t *rwlock)
free (rwlock); free (rwlock);
} }
static pthread_rwlock_t * static inline pthread_rwlock_t *
g_rw_lock_get_impl (GRWLock *lock) g_rw_lock_get_impl (GRWLock *lock)
{ {
pthread_rwlock_t *impl = g_atomic_pointer_get (&lock->p); pthread_rwlock_t *impl = g_atomic_pointer_get (&lock->p);
@ -667,7 +667,7 @@ g_cond_impl_free (pthread_cond_t *cond)
free (cond); free (cond);
} }
static pthread_cond_t * static inline pthread_cond_t *
g_cond_get_impl (GCond *cond) g_cond_get_impl (GCond *cond)
{ {
pthread_cond_t *impl = g_atomic_pointer_get (&cond->p); pthread_cond_t *impl = g_atomic_pointer_get (&cond->p);
@ -1007,7 +1007,7 @@ g_private_impl_free (pthread_key_t *key)
free (key); free (key);
} }
static pthread_key_t * static inline pthread_key_t *
g_private_get_impl (GPrivate *key) g_private_get_impl (GPrivate *key)
{ {
pthread_key_t *impl = g_atomic_pointer_get (&key->p); pthread_key_t *impl = g_atomic_pointer_get (&key->p);