]> 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:23 +0000 (18:41 +0200)
commita4b09af3e93707351f1d4b8efafabfa135c0f70b
tree0ea29a8ec25a8d036f4a376932d5c9ed004dcfa7
parent7039760114da45552043f8fa229928e071650173
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