Skip to content

Commit e722846

Browse files
committed
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
1 parent 8438a3f commit e722846

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3174,11 +3174,11 @@ BackendXidGetPid(TransactionId xid)
31743174

31753175
for (index = 0; index < arrayP->numProcs; index++)
31763176
{
3177-
int pgprocno = arrayP->pgprocnos[index];
3178-
PGPROC *proc = &allProcs[pgprocno];
3179-
31803177
if (other_xids[index] == xid)
31813178
{
3179+
int pgprocno = arrayP->pgprocnos[index];
3180+
PGPROC *proc = &allProcs[pgprocno];
3181+
31823182
result = proc->pid;
31833183
break;
31843184
}

0 commit comments

Comments
 (0)