From: Mark Michelson Date: Fri, 27 Jun 2008 16:23:32 +0000 (+0000) Subject: Optimization suggested by Russell to cache the value of pthread_self() so X-Git-Tag: 1.6.2.0-beta1~1875 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67e2b82951dd07318b476a6c97bf24a42b78669b;p=thirdparty%2Fasterisk.git Optimization suggested by Russell to cache the value of pthread_self() so that it isn't evaluated every time through the loop. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@125880 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 56f7b03f07..92299f3cdb 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -1051,8 +1051,9 @@ static inline int _ast_rwlock_unlock(ast_rwlock_t *t, const char *name, if (lt->reentrancy) { int lock_found = 0; int i; + pthread_t self = pthread_self(); for (i = lt->reentrancy-1; i >= 0; --i) { - if (lt->thread[i] == pthread_self()) { + if (lt->thread[i] == self) { lock_found = 1; if (i != lt->reentrancy-1) { lt->file[i] = lt->file[lt->reentrancy-1];