postgres.git / summary / log / commit / refs

commit    e722846daf4a37797ee39bc8ca3e78a4ef437f51
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Fri Sep 08 01:00:29 2023 +0000
First released in: 17.0

    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


src/backend/storage/ipc/procarray.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index bfbf7f903f5..d93475b2bdd 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/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; } [parent: 8438a3ffef28]