]> granicus.if.org Git - postgresql/commit
Micro optimize LWLockAttemptLock() a bit.
authorAndres Freund <andres@anarazel.de>
Fri, 31 Jul 2015 18:50:35 +0000 (20:50 +0200)
committerAndres Freund <andres@anarazel.de>
Sun, 2 Aug 2015 16:41:41 +0000 (18:41 +0200)
commit9074e41dbd41bc45ef79aeac1b6496bf087509a7
tree803f8e896e6c99e133e0aafbf1bce4a78dad2cdc
parent27b719173516b54df63a1bba4266798e9f77bbb9
Micro optimize LWLockAttemptLock() a bit.

LWLockAttemptLock pointlessly read the lock's state in every loop
iteration, even though pg_atomic_compare_exchange_u32() returns the old
value. Instead do that only once before the loop iteration.

Additionally there's no need to have the expected_state variable,
old_state mostly had the same value anyway.

Noticed-By: Heikki Linnakangas
Backpatch: 9.5, no reason to let the branches diverge at this point
src/backend/storage/lmgr/lwlock.c