• Andres Freund's avatar
    Micro optimize LWLockAttemptLock() a bit. · a4b09af3
    Andres Freund authored
    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
    a4b09af3
lwlock.c 44.8 KB