Improve BackendXidGetPid() to only access allProcs on matching XID
Compilers are able to optimize that, but it makes the code slightly more readable this way. Author: Zhao Junwang Reviewed-by: Ashutosh Bapat Discussion: https://postgr.es/m/CAEG8a3+i9gtqF65B+g_puVaCQuf0rZC-EMqMyEjGFJYOqUUWfA@mail.gmail.com
This commit is contained in:
parent
8438a3ffef
commit
e722846daf
@ -3173,12 +3173,12 @@ BackendXidGetPid(TransactionId xid)
|
|||||||
LWLockAcquire(ProcArrayLock, LW_SHARED);
|
LWLockAcquire(ProcArrayLock, LW_SHARED);
|
||||||
|
|
||||||
for (index = 0; index < arrayP->numProcs; index++)
|
for (index = 0; index < arrayP->numProcs; index++)
|
||||||
|
{
|
||||||
|
if (other_xids[index] == xid)
|
||||||
{
|
{
|
||||||
int pgprocno = arrayP->pgprocnos[index];
|
int pgprocno = arrayP->pgprocnos[index];
|
||||||
PGPROC *proc = &allProcs[pgprocno];
|
PGPROC *proc = &allProcs[pgprocno];
|
||||||
|
|
||||||
if (other_xids[index] == xid)
|
|
||||||
{
|
|
||||||
result = proc->pid;
|
result = proc->pid;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user