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
pull/140/head
Michael Paquier 2 years ago
parent 8438a3ffef
commit e722846daf
  1. 6
      src/backend/storage/ipc/procarray.c

@ -3174,11 +3174,11 @@ BackendXidGetPid(TransactionId xid)
for (index = 0; index < arrayP->numProcs; index++)
{
int pgprocno = arrayP->pgprocnos[index];
PGPROC *proc = &allProcs[pgprocno];
if (other_xids[index] == xid)
{
int pgprocno = arrayP->pgprocnos[index];
PGPROC *proc = &allProcs[pgprocno];
result = proc->pid;
break;
}

Loading…
Cancel
Save