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: http://svn.digium.com/svn/asterisk/trunk@125880 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
1c8883a47e
commit
0b41dddce2
|
@ -1051,8 +1051,9 @@ static inline int _ast_rwlock_unlock(ast_rwlock_t *t, const char *name,
|
||||||
if (lt->reentrancy) {
|
if (lt->reentrancy) {
|
||||||
int lock_found = 0;
|
int lock_found = 0;
|
||||||
int i;
|
int i;
|
||||||
|
pthread_t self = pthread_self();
|
||||||
for (i = lt->reentrancy-1; i >= 0; --i) {
|
for (i = lt->reentrancy-1; i >= 0; --i) {
|
||||||
if (lt->thread[i] == pthread_self()) {
|
if (lt->thread[i] == self) {
|
||||||
lock_found = 1;
|
lock_found = 1;
|
||||||
if (i != lt->reentrancy-1) {
|
if (i != lt->reentrancy-1) {
|
||||||
lt->file[i] = lt->file[lt->reentrancy-1];
|
lt->file[i] = lt->file[lt->reentrancy-1];
|
||||||
|
|
Reference in New Issue